為什麼在ssh客戶端中用-i選項指定私鑰?

為什麼在ssh客戶端中用-i選項指定私鑰?

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.

它指出,身分文件是私鑰。

但這不是違反了私鑰保密的安全原則嗎?

如果 ssh 透過網路傳輸金鑰,則可能會受到損害。

我希望目標機器保留私鑰,並檢查傳入使用者的公鑰。

我的理解有什麼問題嗎?

如果 ssh 透過網路發送私鑰,那麼它比僅使用密碼有什麼優勢?

答案1

SSH 從不透過網路傳送私鑰。事實上,這是愚蠢的。

私鑰僅用於回答來自目標主機的“挑戰”,該“挑戰”是使用相應的公鑰生成的。在不擁有私鑰的情況下回答挑戰是出了名的困難,這使得這種通訊變得安全,因為你不能透過猜測來破壞它(在可接受的時間範圍內)。蠻力。

相關內容