即使将私钥加载到私钥中,ssh-agent
直到将相应的SSH公钥添加到remote之前,您仍然会看到密码提示以解密私钥~/.ssh/authorized_keys
。
复制:
# We are about to ssh to localhost, therefore, unauthorized everyone.
$ rm ~/.ssh/authorized_keys
$ eval $(ssh-agent)
# Agent pid 9290
$ ssh-add
# Enter passphrase for /home/uvsmtid/.ssh/id_rsa:
# Identity added: /home/uvsmtid/.ssh/id_rsa (/home/uvsmtid/.ssh/id_rsa)
$ ssh localhost
# Enter passphrase for key '/home/uvsmtid/.ssh/id_rsa':
# uvsmtid@localhost's password:
# NOTE: See password prompt for private key
# (and only then prompt for remote login).
# Why? Isn't the private key is already loaded by `ssh-add`?
$ ssh-copy-id localhost
$ ssh localhost
# NOTE: No password for private key anymore.
# The key is served by `ssh-agent`.
令人困惑。在这种情况下,远程SSH登录密码就足够了。
我可以推测这会在不知道相应私钥的加密密码的情况下阻止添加您的公钥(与加密的私钥配对)。无论如何,这是一次远程登录过程。