I'm sshing into a remote host and it's picking gssapi-with-mic authentication. How do I set at command line to only use public key? I don't have access to the remote server's /etc/ssh/sshd_config and it seems all the recommendation is for changing the config rather than command line option.


2 Answers 2


That should be with:

ssh -o PreferredAuthentications=publickey host

The default value of PreferredAuthentications according to the manual is: gssapi-with-mic,hostbased,publickey,keyboard-interactive,password.


You can try something like:

ssh -o " AllowedAuthentication=publickey" -i path/to/private_key username@hostname

For the record your private key is located (usually) in ~/.ssh directory

  • 1
    From the manual, I'm not convinced it would cause publickey auth to take precedence over gssapi-with-mic. It would rather bypass the authentication agent. Sep 26, 2021 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.