How to automate SSH login with passphrase-less SSH key



Generate a passphrase-less SSH key

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.{codeBox}


Copy keys to the target server

$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname -p [port_number]
username@server's password {codeBox}

Verify the connection

$ ssh username@hostname -p [port_numer] {codeBox}

Next Post Previous Post