2

ssh with key-based authentication is failing the first time, falling to password based authentication. However, if the user is logged in ( via ssh, or directly on the VM's terminal), then key-based authentication works.

There are a number of proposed solutions on the net, but so far none of them have worked.

Tried taking the /etc/ssh/sshd_config file from another server where I can log in the first time (i.e., no such issue). But on the said VM, this issue continues.

The machine is an Ubuntu 14.x VM running on Virtual Box.

Have looked at these related posts, but they didn't work:

What could 'Roaming not allowed by server' of ssh client mean? -- setting HostbasedAuthentication to yes didn't work. setting UseRoaming to any value caused the ssh server to fail to restart.

Other posts have suggested setting the permissions for ~/.ssh to 700 and ~/.ssh/authorized_keys to 600 -- those aren't making any difference either.

Weird part is, key-based authentication does work when the user is already logged in. On the other hand, if user logs out of all sessions, and tries loggin in again, the password prompt shows up.

Thanks for your thoughts!

4
  • Can you provide the output of ssh -v hostname when it fails?
    – ott--
    Aug 8, 2015 at 20:59
  • 1
    Is the VM set up to use home directory encryption? Aug 8, 2015 at 21:10
  • @grawity yes, the home directory is encrypted. That could be the issue, isn't it?
    – jerry
    Aug 10, 2015 at 21:20
  • Well yes, how is sshd suppsed to read your authorized_keys out of it... Aug 10, 2015 at 22:50

1 Answer 1

0

So the issue is that your home directory is encrypted, and automatically locks again whenever you log out completely.

And if the home directory is encrypted, ~/.ssh/authorized_keys is also encrypted, so sshd cannot determine which keys are allowed.

You'll have to specify a different AuthorizedKeysFile in your sshd_config, or disable ecryptfs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .