Home Miscellaneous Create SSH key to access one server from another without authentication

Create SSH key to access one server from another without authentication

by SupportPRO Admin

Lets name the 2 servers as follows:

Your server >> Server1

Remote server >> Server2

1. Login to Server 1 as root

2. Give the following command to generate a DSA Key Pair.

#ssh-keygen -t dsa

PS: Please create a password different from that of the passphrase

The output should be like this:

Server 1 # ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/root/.ssh/id_dsa): Leave it blank and hit enter

Enter passphrase (empty for no passphrase): Leave it blank and hit enter

Enter same passphrase again: Leave it blank and hit enter

Your identification has been saved in /root/.ssh/id_dsa.

Your public key has been saved in /root/.ssh/id_dsa.pub.

The key fingerprint is:

48:31:d1:32:44:aa:a4:63:0f:4f:7e:87:e6:3c:8e:6d root@1.com

3. Now create a directory “.ssh” under /root on server 2. You can perform this from Server 1

Server 1# ssh root@ServerB mkdir -p .ssh

Server 2’s password:

4. Now insert the the newly created public key to Server2:.ssh/authorized_keys

Server 1# cat .ssh/id_dsa.pub | ssh root@Server2 ‘cat >> .ssh/authorized_keys’

Server 2’s password:

5. Now ssh key is set from Server1 to Server2. You can just type the following from Server1 to enter Server2 without password:

Server 1# ssh IP address of Server2

Server 2#

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment