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!
ssh -v hostname
when it fails?