在 SSHv2 连接初始化期间,有以下调试消息:
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
我是否正确,实际上没有公钥发送到服务器?另外,/home/user/.ssh/id_rsa
是我的私钥。这条消息究竟是什么Offering RSA public key
意思?
在 SSHv2 连接初始化期间,有以下调试消息:
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
我是否正确,实际上没有公钥发送到服务器?另外,/home/user/.ssh/id_rsa
是我的私钥。这条消息究竟是什么Offering RSA public key
意思?
当 SSH 客户端显示此消息时,它正在尝试对服务器上的用户 ( userauth_pubkey
insshconnect2.c
) 进行身份验证。客户端需要证明它拥有与服务器授权的公钥对应的私钥。调试消息中显示的文件名是私钥文件的名称(例如,作为参数传递给-i
或作为IdentityFile
配置指令传递)。
在显示此消息时,客户端不使用私钥,只使用公钥。但是,客户端想知道私钥是可用的,因为如果服务器同意使用这个公钥,那么客户端必须证明它知道私钥。客户端使用包含公钥的方法向服务器发送SSH_MSG_USERAUTH_REQUEST
消息。如果服务器同意使用这个公钥(“debug1:服务器接受密钥”),那么客户端稍后将使用私钥签署服务器在另一条消息中发送的质询(在-字节从 0 更改(“告诉我如果你喜欢这把钥匙”)到 1(“这是我是我的证明,让我进来”))。publickey
SSH_MSG_USERAUTH_REQUEST
sign_and_send_pubkey
have_sig
我的猜测是客户宣布他正在使用的密钥对,并提供公钥(当然!)。但实际上,该消息给出的密钥是一个私钥,我不完全理解为什么。我尝试使用ssh -vvv
我使用的服务器:
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/user/.ssh/id_dsa
debug3: no such identity: /home/user/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug3: no such identity: /home/user/.ssh/id_ecdsa: No such file or directory
debug1: Offering ED25519 public key: /home/user/.ssh/id_ed25519
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-ed25519 blen 51
由于我在这台计算机上有 2 个密钥:RSA 一个和 ECDSA 一个,看起来服务器拒绝了我的 RSA 密钥。没关系,我没有向此服务器提供 RSA 密钥。然后,他试图找到一个 DSA 和一个 ECDSA 密钥,但我没有这些,所以“没有这样的身份”是可以理解的。然后,我拥有一个 ED25519 密钥,它会尝试这个。一切顺利,因为我将此密钥对注册到该服务器。请注意,它现在接受我的公钥!
然后,协议继续通过挑战运行,服务器现在知道使用哪个公钥来加密挑战,客户端(我的机器)知道使用哪个私钥来进行挑战。