How Do You Set up Passwordless SSH from One Server to Another?

Problem scenario
You want to configure passwordless SSH between two servers such that you can log in from server A to server B with no password.  You want to be able to use scp between the two servers without being challenged for a password.  How do you set up passwordless SSH between them?

Solution

Assumptions
Assuming both servers have a local user account named "ubuntu", the following will work.  This assumes that relevant firewalls allow port 22 connections between the two servers.  If one server is in AWS and another is in Azure, please see this posting.  If you have a Windows server, you will need to install Cygwin on it; see this posting if you do not know how.  If you have Linux servers, just follow the procedures below.

Procedures
1.  On server A, run this command:  ssh-keygen -t rsa -P ""
#  You will be prompted after you run the above command.  Press enter to accept the default location to save the key.

2.  Then run this command:  cat /home/ubuntu/.ssh/id_rsa.pub

3.  Append the output of the above command to a file on server B.  This file on server B to receive this appendage is this: /home/ubuntu/.ssh/authorized_keys

4.  You are done.  From server A you will now be able to use ssh ubuntu@x.x.x.x (where x.x.x.x is server B's IP address) and authenticate without a password.  If you want server B to be able to passwordlessly connect to server A, repeat the above steps but substitute the roles "server A" with "server B."

Leave a comment

Your email address will not be published.