为什么在 ssh 客户端中使用 -i 选项指定私钥?

Dim*_*ims 1 security ssh key-authentication

在 ssh man 中是这样说的:

-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 con?
             figuration file.  It is possible to have multiple -i options (and multiple identities specified in configura?
             tion 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 file?
             names.
Run Code Online (Sandbox Code Playgroud)

它指出,该身份文件是一个私钥。

但这不违反安全原则,私钥应该保密吗?

如果 ssh 通过网络传输密钥,它可能会受到损害。

我希望,目标机器保留私钥,并检查传入用户的公钥。

我的理解有什么问题?

如果 ssh 通过网络发送私钥,那么它与仅使用密码相比有什么优势?

小智 7

SSH 从不通过网络发送私钥。事实上,这将是愚蠢的。

私钥仅用于回答来自使用相应公钥生成的目标主机的“挑战”。在不拥有私钥的情况下回答挑战是出了名的困难,这使得这种通信变得安全,因为您无法通过猜测来破坏它(在可接受的时间范围内)。蛮力。