SSH Passwordless Login Using SSH Keygen in 5 Easy Steps

NB: Follow this guide for Jenkins CD

Using Password-less login with SSH keys will increase the trust between two Linux servers for easy file synchronization or transfer.

SSH Client : 192.168.0.10 
SSH Remote Host : 192.168.0.11 

In this example, we will set up SSH password-less automatic login from server 192.168.0.10 as user bob to 192.168.0.11 with user fred. Please note that ALL commands are run via the SSH Client 192.168.0.10

Step 1: Create Authentication SSH-Keygen Keys on 192.168.0.10

ssh-keygen -t rsa

Step 2: Create .ssh Directory on – 192.168.0.11 (via 192.168.0.10)

ssh -p 22 fred@192.168.0.11 mkdir -p .ssh

Step 3: Upload Generated Public Keys to – 192.168.0.11 (via 192.168.0.10)

cat .ssh/id_rsa.pub | ssh -p 22 fred@192.168.0.11 'cat >> .ssh/authorized_keys'

Step 4: Set Permissions on – 192.168.0.11 (via 192.168.0.10)

ssh -p 22 fred@192.168.0.11 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

Step 5: Login from 192.168.0.10 to 192.168.0.11 Server without Password

ssh -p 22 fred@192.168.0.11