SSH Cant Connect : Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password

If you have installed keypair and the remote machine still asking for the password, you can follow the below steps.

You may see the following errors:

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic

The reason behind the issue is the user's home directory is encrypted and the connecting machine can't access the keys. So you need to change the location of the key to somewhere else.

mkdir /etc/ssh/theg

cp ~/.ssh/authorized_keys /etc/ssh/theg/

Edit /etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      /etc/ssh/theg/authorized_keys

Restart the ssh service:

service sshd restart

Try logging now. Enjoy !!! 🙂

ps : use the verbose option in ssh to get more details : ssh -C root@IP -v