How to Setup Passwordless SSH on Linux

Passwordless SSH is a way to log in to a remote server without entering the password. It works based on a special algorithm to create secure keys (public and private). These key pairs make the login process more secure and convenient. In short, the Passwordless SSH or SSH without password method is commonly used for securing file transfer to the remote server.

This learning-based guide explains the complete process of setting up and configuring passwordless SSH on a Linux system.

How to Setup Passwordless SSH on Linux (Ubuntu 22.04)?

Here are the essential steps to set up passwordless SSH on Linux-based systems, such as Ubuntu 22.04.

How to Install OpenSSH on Linux (Ubuntu 22.04)?

For configuring passwordless SSH, you must have OpenSSH installed on your Linux system. 

Step 1: Refresh and Update Package List

To improve your system performance, it is advised to run the update command before installing new packages:

sudo apt update
sudo apt update

The command refreshes the list of system packages and notifies you of any outdated packages.

Step 2: Install OpenSSH via APT

If the OpenSSH package is not already installed on your Linux system, you can easily install it from the Ubuntu repository using the apt package manager:

sudo apt install openssh-server -y
sudo apt install openssh
sudo apt install openssh

After completing the installation, you can initiate the passwordless SSH setup on your Linux system.

Step 3: Check SSH Status

From the Linux terminal, you can verify the status of the OpenSSH service to ensure it is running properly:

sudo systemctl status ssh
sudo systemctl status ssh

Before proceeding to the next step, confirm that your SSH service status is active (running). 

Note: You cannot set up passwordless SSH if the SSH is not active. 

How to Generate RSA Key Pair for SSH on Linux (Ubuntu 22.04)? 

Let’s generate the RSA Public key pair for passwordless authentication using the following steps.

Step 1: Generate Public Key Pair

Execute this OpenSSH command to create an SSH key pair:

ssh-keygen 
ssh-keygen

The command will display the necessary details such as the path of the generated key (id_rsa and id_rsa.pub), the algorithm (RSA), and the number of bits (3072).

Step 2: Transfer the Generated Key to Remote Server

The command, such as ssh-copy-id followed by a remote server address, will transfer the generated RSA key to the remote server:

ssh-copy-id [email protected]
ssh-copy-id

During the key transfer process, you will be prompted to enter the password against the particular user ([email protected]) to complete the process.

Step 3: Test SSH 

Confirm the SSH configuration by testing the connection to the remote server using the following command:

ssh [email protected]
ssh

You will see a welcome note on your terminal screen that shows your SSH has been successfully configured on Linux. 

How to Configure Passwordless SSH on Linux (Ubuntu 22.04)?

Customize the SSH configuration file to enable passwordless SSH through these steps.

Step 1: Setup Passwordless SSH

To customize the file for passwordless SSH, access the SSH configuration file through the command:

sudo nano /etc/ssh/sshd_config
sudo nano

Locate the line containing the keyword “PasswordAuthentication” and set it to “no”. You can use Ctrl + w from keyboard to find the keyword: 

PasswordAuthentication no
passwordauthentication no

Save the changes by pressing Ctrl + S and return to the terminal window by closing the SSH configuration file. 

Step 2: Restart SSH Service

After making the required changes in the SSH configuration file, restart the SSH service to ensure the changes take effect:

sudo systemctl restart ssh
sudo systemctl restart ssh

The empty output indicates that the command successfully applied the changes made in the configuration file.

Step 3: Close Remote Server

After configuring passwordless SSH, you can exit the remote server with the command:

exit 
exit

After following the steps as mentioned above, you have successfully set up passwordless SSH on your Linux-based system.

Conclusion

Passwordless SSH can be configured and set up on Linux using simple steps. First, ensure that OpenSSH is installed on your Linux system. Then, after creating a public key pair, customize the SSH configuration file of the specific remote server to enable passwordless SSH on your system. 

This article explained the detailed process of setting up passwordless SSH on Linux-based systems. 

Set up passwordless SSH on Linux by creating a key pair and customizing the SSH configuration file to enable passwordless SSH on your Instant VPS system.

FAQ

What is Passwordless SSH and why would I want to set it up?
How do I generate SSH keys?
What are private and public keys?
How do I copy my public key to the remote server?

Related Post

How to Install and Connect to Linux Server wi

In the evolving field of information technology, remote...

How to Create a Bash Script: Step-by-Step Gui

Bash scripts are powerful tools that allow you to autom...

How to Remove the Lock Symbol from Files and

The lock symbol primarily indicates restricted or limit...

How to Fix Systemctl Command Not Found Error

Linux operating systems use the "systemctl" command to ...

Explore the man (Manual) Command in Linux

The man command, short for “manual”, is an essentia...

How to Fix “ifconfig: Command not Found

Displaying the error "ifconfig: command not found" on a...

Leave a Comment