每个连接都需要 SSH 密钥

每个连接都需要 SSH 密钥

我在计算机上安装了 ssh 密钥来连接到服务器,为什么即使我尝试连接到其他服务器,它仍要求我插入该密钥的密码?

答案1

密钥文件如何命名?

如果您安装的密钥的名称是id_rsa/ id_rsa.pubetc 那么ssh如果服务器有的话将始终尝试使用它进行PubkeyAuthentication yes连接/etc/ssh/sshd_config

如果在连接到该服务器时将文件的默认名称重命名,则必须使用ssh -i /path/to/key,否则每次使用时ssh都会尝试使用这些密钥(如果它们正在使用任何默认密钥名称)。

man ssh

-i identity_file
             Selects a file from which the identity (private key) for public
             key authentication is read.  The default is ~/.ssh/identity for
             protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
             ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
             Identity files may also be specified on a per-host basis in the
             configuration file.  It is possible to have multiple -i options
             (and multiple identities specified in configuration files).  If
             no certificates have been explicitly specified by the
             CertificateFile directive, ssh will also try to load certificate
             information from the filename obtained by appending -cert.pub to
             identity filenames.

相关内容