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 know this question has been asked, but I'm certain I've done what all the other answers suggest.

Machine A:

  • used keygen -t rsa to create in ~/.ssh/
  • copied Machine A's to Machine B user's home directory
  • Made the file permissions of 600

Machine B

  • added Machine A's pub key to authorised_keys and authorised_keys2: cat ~/ >> ~/.ssh/authorised_keys2
  • made the file permissions of 600

I've also ensured both the .ssh directories have the permission 700 on both machine A and B.

If I try to login to machine B from machine A, I get asked for the password, not the ssh pass phrase.

I've got the root users on both machines to talk to each other using password-less ssh, but I can't get a normal user to do it.

Do the user names have to be the same on both sides? Or is there some setting else where I've missed.

Machine A is a Ubuntu 10.04 virtual machine running inside VirtualBox on a Windows 7 PC, Machine B is a dedicated Ubuntu 9.10 server

UPDATE : I've run ssh with the option -vvv, which provides many many lines of output, but this is the last few commands:

debug3: check_host_in_hostfile: filename /home/pete/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host '' is known and matches the RSA host key.
debug1: Found key in /home/pete/.ssh/known_hosts:1
debug2: bits set: 504/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: Wrote 16 bytes for a total of 1015
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug3: Wrote 48 bytes for a total of 1063
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/pete/.ssh/identity ((nil))
debug2: key: /home/pete/.ssh/id_rsa (0x7ffe1baab9d0)
debug2: key: /home/pete/.ssh/id_dsa ((nil))
debug3: Wrote 64 bytes for a total of 1127
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/pete/.ssh/identity
debug3: no such identity: /home/pete/.ssh/identity
debug1: Offering public key: /home/pete/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug3: Wrote 368 bytes for a total of 1495
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/pete/.ssh/id_dsa
debug3: no such identity: /home/pete/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
share|improve this question
Im sure you meant .ssh/authorized_keys? Cause that's the correct name for the file. – Alexander Janssen Oct 3 '12 at 16:09
The name of the authorized_keys file is set in your /etc/ssh/sshd_config file. If it's still failing, running your ssh command with -vvv can help find the problems. – Ladadadada Oct 3 '12 at 17:00
Sorry that was just a typo, I've updated that. – Willshaw Media Oct 4 '12 at 7:01

Use ssh-copy-id to copy your keys; it will create any necessary files/directories and fix any broken permissions along the way.

share|improve this answer
I agree. Using ssh-copy-id removes almost all the general pitfalls you encounter when doing key-based authentication. If it still doesn't work it's either that it's not enabled in the sshd_config or selinux. – Alexander Janssen Oct 3 '12 at 17:30

file name has to be: authorized_keys2 and it should be chmod 600.

~/.ssh (700)
~/.ssh/authorized_keys2 (600)
~/.ssh/id_rsa (600)
~/.ssh/ (644)

* UPDATE * : provide output of following (from a remote server):

ls -ld ~/.ssh ~/.ssh/authorized_key*

Is SELinux enabled? (use: getenforce), are you getting Permissive or Enfrocing?

share|improve this answer
All of my keys are in a plain authorized_keys file – Iain Oct 4 '12 at 7:12
'getenforce' is currently not installed. Do I need it? – Willshaw Media Oct 4 '12 at 7:28

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.