January 11

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.


Copyright 2021. All rights reserved.

Posted January 11, 2012 by Timothy Conrad in category "Linux

About the Author

If I were to describe myself with one word it would be, creative. I am interested in almost everything which keeps me rather busy. Here you will find some of my technical musings. PGP: 4CB8 91EB 0C0A A530 3BE9 6D76 B076 96F1 6135 0A1B