Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

When I execute the command ssh localhost (in Ubuntu 10.10), it will display the error message "permission denied(public key)." What may be the problem?

Is there any problem in sshd_config file in /etc/ssh? Should PasswordAuthentication be set to no? I have set the PasswordAuthentication to no, but still it gives me the error "permission denied(publickey)."

share|improve this question
Did you disable password authentication in sshd_config? Why? What you are trying to do with this? – ulidtko Apr 26 '11 at 8:47

you need to set file permissions right , try this ..

 $chmod go-w ~/
 $chmod 700 ~/.ssh
 $chmod 600 ~/.ssh/authorized_keys
share|improve this answer
@Volution2111Volution2111:thanks ya.. its worked fine now, I hv set the permissions.. – priyaudupi Apr 27 '11 at 2:57
@Statwonk, what? His answer is completely valid, an incorrect permission is going to cause ssh keys to fail automatically, and the ~/.ssh is the default home directory that ssh keys are stored to on almost all *nix distros. – Michael Ryan Soileau Jul 17 '15 at 23:15
@MichaelRyanSoileau you're right, I don't remember making this comment, but it clearly looked wrong (removed it). Thanks for raising it to me! – Statwonk Jul 18 '15 at 0:22


ssh-copy-id -i ~/.ssh/ user@host

Or since you are on localhost try copyting your ssh key (rsa or dsa) inside a file $HOME/.ssh/authorized_keys

For key authentication in ssh you need to authorize your keys on host first AFAIK.

share|improve this answer
thanks – priyaudupi Apr 26 '11 at 6:49
hey still it does not work ya.. what is the problem do u kw?? – priyaudupi Apr 26 '11 at 7:26

Make sure you've installed "openssh-server" because it's not installed by default.

sudo apt-get install openssh-server

share|improve this answer
If it was not installed, OP would not get an error message at all, but hang. – Lekensteyn Apr 26 '11 at 8:52

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.