`ssh` запрашивает пароль закрытого ключа, даже если ключ добавлен в` s sh -agent` - PullRequest
0 голосов
/ 14 февраля 2020

Я создал виртуальную машину с пользователем по имени firstuser и паролем. Я не скопировал ключ publi c этого пользователя ~/.ssh/authorized_keys (в виртуальной машине). У меня есть закрытый ключ, добавленный к ssh-agent на хосте, как обычно на моем хосте. Мой закрытый ключ защищен паролем.

Когда я пытаюсь подключиться к виртуальной машине sh, мне предлагается ввести пароль для разблокировки закрытого ключа. Я не понимаю, почему s sh сделал бы это, и почему он не будет искать этот ключ в кэше ssh-agent!

Вот сеанс, демонстрирующий все, что я заявляю выше.

$ env | grep SSH
SSH_CONNECTION=127.0.0.1 49064 127.0.0.1 22
SSH_AUTH_SOCK=/home/gurjeet/.ssh/ssh_auth_sock
SSH_CLIENT=127.0.0.1 59624 22
SSH_TTY=/dev/pts/0

$ ssh-add -L
ssh-rsa AAAAB3Nz<redacted>qVLQ== /home/gurjeet/.ssh/id_rsa

$ ssh -v firstuser@192.168.122.218
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/gurjeet/.ssh/config
debug1: /home/gurjeet/.ssh/config line 28: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.122.218 [192.168.122.218] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gurjeet/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.0
debug1: match: OpenSSH_8.0 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.122.218:22 as 'firstuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:j5RF+llw1typVOaMlSvKZ681qh524itEDQbFVIVSxVk
debug1: Host '192.168.122.218' is known and matches the ECDSA host key.
debug1: Found key in /home/gurjeet/.ssh/known_hosts:12
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1001)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1001)

debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:yNbLOoGlcisMcRGDBzTSKIZ1Rg0oy2mve2fWD5J3jqo /home/gurjeet/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/gurjeet/.ssh/id_rsa
Enter passphrase for key '/home/gurjeet/.ssh/id_rsa': << just pressed enter >>
debug1: Trying private key: /home/gurjeet/.ssh/id_dsa
debug1: Trying private key: /home/gurjeet/.ssh/id_ecdsa
debug1: Trying private key: /home/gurjeet/.ssh/id_ed25519
debug1: Next authentication method: password
firstuser@192.168.122.218's password: << entered the password here >>
debug1: Authentication succeeded (password).
Authenticated to 192.168.122.218 ([192.168.122.218]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_TERMINAL = iTerm2
debug1: Sending env LC_TERMINAL_VERSION = 3.3.7
Last login: Fri Feb 14 00:10:15 2020 from 192.168.122.1
[firstuser@localhost ~]$ cat .ssh/authorized_keys
[firstuser@localhost ~]$ exit
logout
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to 192.168.122.218 closed.
Transferred: sent 3052, received 3148 bytes, in 11.1 seconds
Bytes per second: sent 275.6, received 284.3
debug1: Exit status 0

$

PS: После тщательного поиска нашел этот вопрос, который может выглядеть как дубликат, но предложенное решение и описанный в нем симптом не относятся к моему случаю.

Git спросить для парольной фразы S SH, даже если она присутствует в агенте s sh

...