Passwordless SSH (Secure Shell) between two machines is required by a lot of distributed frameworks. It creates a secure shell connection from the host machine to the remote machine without password prompt.

Follow the steps below to configure Passwordless SSH between two linux machines.


1. Install Open SSH Server package on your machines. This will also start sshd service on port 22 on your machines.



[NOTE: Now by default all operating system comes with pre-installed “Open SSH Server”, so you won’t need to install it.]

2. Check the status of sshd service and start the service if the status is not running.

Ubuntu: Command Output will look like  “* sshd is running” OR “* sshd is not running” 

Centos: Command Output will look like “openssh-daemon (pid  985) is running…” OR “openssh-daemon is stopped”

Steps for Passwordless ssh

1. Install ssh keys on your machine. The command will create an ~/.ssh/ folder for the current user and the folder will have the public ( and private (id_rsa) key pair. Execute the command mentioned below:

Note: If you are getting Permission Denied error while generating the Public and Private keys, then make sure that the SELinux is disabled on your machines. To disable SELinux, you can read here

2. To enable Passwordless SSH to a remote machine, you need to copy the contents of your public key file ( to the ~/.ssh/authorized_keys file of the remote machine. ssh-copy-id command is the easiest way to copy the key to the remote machine. You need to specify the user and the hostname of the remote machine. If the user is not specified, it’ll take the user executing the command as the default user. Execute the following command on the host machine.

Replace the <username> and <hostname> by the actual username and hostname of the remote system. This command will prompt for the password for <username>@<hostname>.

For Example, on node1 run below commands: (This will make Passwordless SSH from node1 to node2)

The output of the above command will look like:
Similarly, on node2 run below commands: (This will make Passwordless SSH from node2 to node1)
3. Passwordless SSH configured successfully. You can now use the ssh command to verify the same.
Share this:

One thought on “Passwordless SSH between linux machines

Leave a Reply

Your email address will not be published. Required fields are marked *