Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed a guide for password-less login:

# Generate Key

#Append Key
cat ~/.ssh/ | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys'


... I opened authorized_keys to make sure the key was added, but I still have to enter password to login.

I even tried copying with ssh-copy-id and the keys get added successfully, but still it asks for password.

myname-MBP:~ mynameezzy$ ssh "ls -la .ssh"'s password: 
total 28
drwxr-xr-x 2 myname neouser 4096 Sep 14 09:58 .
drwxrwxr-x 7 myname myname 4096 Sep 14 12:02 ..
-rw-rw-r-- 1 myname neouser  811 Sep 15 01:38 authorized_keys
-rw-rw-r-- 1 myname neouser  400 Sep 12 02:32 authorized_keys.bak
-rw------- 1 myname neouser 1675 Sep 11 11:27 id_rsa
-rw-r--r-- 1 myname neouser  400 Sep 11 11:27
-rw-r--r-- 1 myname neouser 1010 Sep 14 09:58 known_hosts

What am I doing wrong?

share|improve this question
Check the server's logs to find out what went wrong. – Michael Hampton Sep 15 '13 at 5:43
And edit into your question the output of ssh user@remotehost "ls -la .ssh". – MadHatter Sep 15 '13 at 5:59
@MadHatter added output – Nimbuz Sep 15 '13 at 6:12
@MichaelHampton I checked in ~/logs and /logs, didn't find anything. – Nimbuz Sep 15 '13 at 6:22
Nimbuz, the etiquette around these parts is that when you're satisfied with an answer to your question, you accept it by clicking the tick outline next to it. This drives the SF reputation system both for you and the author of the accepted answer. I apologise if you already know this, but you have several older SF questions with valid answers, none of which have been accepted; you might want to go back and review those. – MadHatter Sep 15 '13 at 6:39
up vote 4 down vote accepted

On remotehost, try

chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys

Edit: I find the fast way to sort out most of these problems is to run a second, non-detaching, logging sshd on another port on the remote server, and connect to that.

On server: /usr/sbin/sshd -d -p 2222

On client: ssh remotehost -p 2222

Then look closely at STDOUT from the non-detaching sshd. You may need to open up an inbound port on remotehost's firewall; in this case, 2222.

share|improve this answer
<grin> thanks, Michael! – MadHatter Sep 15 '13 at 6:37
Thanks, but still asks for password :( – Nimbuz Sep 15 '13 at 7:00

Change permission for your .ssh directory

  chmod 700 $HOME/.ssh
  chmod 600 $HOME/.ssh/authorized_keys
share|improve this answer
You don't want to make that recursive. – Michael Hampton Sep 15 '13 at 6:41

SSH is fairly simple, so assuming you haven't made any config changes, there isn't a whole lot to troubleshoot.

Are you able to use your client to log in with SSH and public key to any machine at all?

Visually verify that the public key on the host machine matches the public key on the client. Seems dumb, I know, but I've messed this up before. I usually just do a quick check that the first and last ~20 characters match and there are no spaces.

Verify that on the host machine /etc/ssh/sshd.conf has the following:

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      %h/.ssh/authorized_keys

Make the group of .ssh/ directory and its contents the same group as the user on both machines.

chown username:username -R ~/.ssh/

Try logging in by requiring key use

ssh -i .ssh/ username@servername
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.