1

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.

A1122
  • 111
  • 1
  • Related: [How to force ssh client to use only password auth?](https://unix.stackexchange.com/questions/15138/how-to-force-ssh-client-to-use-only-password-auth) – steeldriver Sep 24 '21 at 17:54

2 Answers2

4

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.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
0

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

Romeo Ninov
  • 16,541
  • 5
  • 32
  • 44
  • 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. – Stéphane Chazelas Sep 26 '21 at 11:50