Answers:
将以下内容添加到您的~/.ssh/config:
PasswordAuthentication no
并在服务器上禁用密码身份验证,请在该行中添加同一行/etc/ssh/sshd_config并重新启动sshd。
在(或~/.ssh/config)命令行上,您可以进行设置PreferredAuthentications。
PreferredAuthentications=publickey
ssh -o PreferredAuthentications=publickey
ssh "-oPreferredAuthentications publickey"
ssh user@host -oPreferredAuthentications=publickey -C 'echo success'