Adding ssh key results in "Connection closed by "
im trying to add to a ssh server of mine ssh key pairs so i can log in password-less.
When i add my public key to my server by creating a .svn and authorized_keys, when i remove it i can log in again (with a password prompt).
Not sure what else to do but i tried generating a rsa ssh-keygen -t rsa. Not sure what else to do. Thanks guys
Solution 1:
The most common problem when setting up passwordless login with SSH is getting the permissions of your .ssh
directory and the authorized_keys
files wrong. SSH is fussy about permissions - with good reason; the wrong permissions can compromise your security.
The permissions should be at least this restrictive:
$ ls -la .ssh
total 28
drwx------ 2 user group 4096 2011-10-05 16:08 .
drwxr-xr-x 4 user group 4096 2012-04-03 12:16 ..
-rw------- 1 user group 405 2011-10-05 16:08 authorized_keys
-rw-r--r-- 1 user group 15912 2012-03-24 10:17 known_hosts
You can achieve this with:
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
The second most common error is spelling authorised_keys
correctly and having SSH ignore the file because it was written by Americans.
The error messages for permissions appear on the server, in the logs and not in the client so it can be tricky to find this.
I have also run into the problem with my public key being split over two lines in .ssh/authorized_keys
. Due to the split happening exactly at the end of the line, it isn't obvious. An editor like vi
makes it easy to tell. Resizing your terminal window should also cause it to re-wrap and clearly show any split lines.
I assumed you meant .ssh
in your question and not .svn
. If you did actually create a .svn
directory, you will need to change it to ssh
.