When I attempt to ssh into my remote server, sometimes my terminal asks me for the username password, and sometimes it asks me for the ssh key passphrase. Is this normal? How can I have it always just ask for the ssh key passphrase?

I am using Gitbash with Windows. I am using a config file to specify the host.

My config file is setup as follows:

Host remoteservername
    Hostname serverbox.net
    User samplename
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes

and then to ssh in I am doing:

ssh remoteservername

Sometimes I get back this:

[email protected]'s password: 

Other times I get back what I want, the request for the passphrase:

Enter passphtase for key 'c/Users/name/.ssh/id_rsa'

The username password is long and complex, so I would ideally like to always just use the ssh key.

The current setup works, except for when it randomly asks for the username password instead of the key phrase.

UPDATE:

As per VonC I ran ssh -Tvv and compared the logs of a successful return versus an incorrect return. Most of the logs were identical until the very end. The attempt that resulted in asking for the username password had these lines:

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
[email protected]'s password:

the correct response returns these lines instead:

debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug2: input_userauth_pk_ok: fp SHA256:{KEY HERE}
Enter passphrase for key '/c/Users/name/.ssh/id_rsa':

Is this possibly something wrong with my ssh itself? Or could it be a configuration issue on the server?

1 Answers

0
VonC On

Try an ssh -Tvv remoteservername multiple times to see if there is any difference between a successful session and one where it defaults back to the user password.

Double-check your PATH and see if the issue persists within a session launched with a simplified PATH (as in here)