rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

Bypass SSH login

Posted on Friday December 02, 2011 by Eric Potvin

If you are using SSH a lot (either to connect from your development environment or production environment) you will be prompted to enter your password:'s password:

This can be annoying when you connect to these servers over and over. Here's a quick tip that will allow you not to enter your password every time you login and keep your connection between your computer and your server secure.

On your computer

cd ~/.ssh

Then execute:

ssh-keygen -t dsa

For each question, simply press the enter key at every prompt. This will output something like (this may vary):

Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/
The key fingerprint is:
The key's randomart image is:
+--[ DSA 1024]----+
|                 |
|     . .         |
|      +          |
|     + . .       |
|    o = S .      |
| . + = + .       |
|. o @ = .        |
| . B oEo .       |
|  . .  .o        |

This produces two files: (public key) and id_dsa (private key)

user@computer:~/.ssh$ ll
total 40
-rw------- 1 user user  668 2011-11-29 13:26 id_dsa
-rw-r--r-- 1 user user  604 2011-11-29 13:26

On your server

Edit the file ~/.ssh/authorized_keys. Note: the file might not be there

vi ~/.ssh/authorized_keys

Copy the content from the public key ( in the ~/.ssh/authorized_keys and change the permissions:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Logout of your server, and login again! the password is now gone!

If by any bad luck you are getting this error:

Agent admitted failure to sign using the key.

Simply, run: