Linux: SSH Key Authentication without Password
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
33:32:19:da:34:42:bc:19:ce:de:62:12:64:f0:da:ca [email protected]
The key’s randomart image is:
+–[ RSA 2048]—-+
| oo+.o o. |
| =o+.+ |
| .= .. |
| . o o.o |
| o + S. |
| . . . . |
| E .. |
| ..o |
| o.. |
Copy the newly created .pub to the server you are wanting to connect to.
eg. scp .ssh/id_rsa.pub [email protected]:pc_key.pub
Next you need to login to the server you would like to login to using your key.
ssh [email protected]
mkdir .ssh (This is done in the root users folder)
cat pc_key.pub >> .ssh/authorized_keys
chmod 700 .ssh
chmod 640 .ssh/authorized_keys
Now you can log off the server and log back in, this time it will not ask you for your password.