Skip to content

How To: Linux SSH Key Authentication without Password

by Jon on June 18th, 2011

When logging in and out of linux servers all day it makes it a lot easier to use key authentication. I usually install my key on any servers that I use often throughout the day. There are some tutorials on the web on how to do this but a lot of them leave out the proper permissions for the .ssh directory and authorized_keys file, which when logging in doesn’t work is the problem 95% of the time.

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:
19:33:32:ca:35:52:be:09:be:dc:52:11:68:f0:ca:ca root@vmware
The key's randomart image is:
+--[ RSA 2048]----+
|    oo+.o o.     |
|     =o+.+       |
|     .= ..       |
|   . o o.o       |
|    o + S.       |
| . . .  .        |
|  E   ..         |
|     ..o         |
|      o..        |
+-----------------+
scp .ssh/id_rsa.pub root@192.168.100.10:my_key.pub

Next you need to login to the server you would like to login to using your key.

ssh root@192.168.100.10
mkdir .ssh
cat my_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.

From → Linux

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

%d bloggers like this: