SSH keyless login with 2048 bit RSA key

1. Login to Server A and Generate key  ( You can generate RSA or DSA key ). I am demonstration RSA key with 2048 bit

hostAuser@hostA:~$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/hostAuser/.ssh/id_rsa):[enter] 
Enter passphrase (empty for no passphrase): [enter]
Enter same passphrase again: [enter]
Your identification has been saved in /export/home/hostAuser/.ssh/id_rsa.
Your public key has been saved in /export/home/hostAuser/.ssh/

2. After key generated there are 2 files created under /export/home/hostAuser/.ssh


3. Copy the key to Server B under /export/home/hostBuser/.ssh/authorized_keys

hostA# cat ~/.ssh/ | ssh hostBuser@hostB “mkdir -p /export/home/hostAuser/.ssh && cat >> /export/home/hostAuser/.ssh/authorized_keys”

4. Change the permissions 

chmod 700 /export/home/hostBuser/.ssh
chmod 644 /export/home/hostBuser/.ssh/authorized_keys

5. Validate the keyless entry by ssh from hostA to hostB

hostA $ ssh hostB


Troubleshooting Steps 

1. Telnet to destination server with port 22

    > telnet hostb 22

    If telnet port 22 is not working then Open firewall port 22

3. Verify the permission on directory and authorized keys

    .ssh 700
    authorized_keys 644


Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (14 votes, average: 5.00 out of 5)

3 thoughts on “SSH keyless login with 2048 bit RSA key

Add Comment