Назад | Перейти на главную страницу

Почему мой закрытый ключ принимается по SSH только после входа в систему на целевой машине?

У меня интересная ситуация, и я даже не знаю, с чего начать расследование. У меня есть сервер Ubuntu 12.04 с SSH, заблокированным для PK-auth. Когда я перезагружаю свой сервер и пытаюсь подключиться к нему по SSH, мой ПК не принимается. Однако, как только я вхожу на свой сервер и снова пытаюсь подключиться к SSH, ПК принимается. Что здесь происходит?

Журнал SSH с клиентского компьютера до входа на сервер:

~ 21:45:00

[earth@p2mac:~]$ssh myuser@myhost.me-v
OpenSSH_6.9p1, LibreSSL 2.1.7
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to myhost.me [xxx.xxx.xxx.177] port 22.
debug1: Connection established.
debug1: identity file /Users/earth/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to myhost.me:22 as 'myuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client xxxx@openssh.com <implicit> none
debug1: kex: client->server xxxxx@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:YZCmzxxxxxxxxxxxxxxxxxxxg3w/39A
debug1: Host ‘myhost.me’ is known and matches the ECDSA host key.
debug1: Found key in /Users/earth/.ssh/known_hosts:26
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/earth/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/earth/.ssh/id_dsa
debug1: Trying private key: /Users/earth/.ssh/id_ecdsa
debug1: Trying private key: /Users/earth/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
[earth@p2mac:~]$

После авторизации на сервере:

~21:47:00

[earth@p2mac:~]$ssh myuser@myhost.me -v
OpenSSH_6.9p1, LibreSSL 2.1.7
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to myhost.me [xx.xx.xxx.177] port 22.
debug1: Connection established.
debug1: identity file /Users/earth/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/earth/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to myhost.me:22 as 'myuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client xxxx@openssh.com <implicit> none
debug1: kex: client->server xxxx@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:YZCxxxxxxxxxxxxoxxxhFNkCg3w/39A
debug1: Host ‘myhost.me’ is known and matches the ECDSA host key.
debug1: Found key in /Users/earth/.ssh/known_hosts:26
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/earth/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to myhost.me ([xxx.xxx.xxx.177]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_ALL = POSIX
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-43-generic x86_64)

Полный журнал авторизации после загрузки:

Jan 18 21:45:14 myhost sshd[1614]: Server listening on 0.0.0.0 port 22.
Jan 18 21:45:14 myhost sshd[1614]: Server listening on :: port 22.
Jan 18 21:45:15 myhost CRON[1632]: pam_unix(cron:session): session closed for user myuser
Jan 18 21:45:15 myhost CRON[1633]: pam_unix(cron:session): session closed for user myuser
Jan 18 21:45:15 myhost CRON[1634]: pam_unix(cron:session): session closed for user myuser
Jan 18 21:45:29 myhost sshd[2417]: Connection closed by xx.xxx.xxx.177  [preauth]
Jan 18 21:46:55 myhost login[2431]: pam_ecryptfs: Passphrase file wrapped
Jan 18 21:46:57 myhost login[2259]: pam_unix(login:session): session opened for user myuser by LOGIN(uid=0)
Jan 18 21:46:57 myhost systemd-logind[740]: New session c2 of user myuser.
Jan 18 21:47:03 myhost sshd[2514]: Accepted publickey for myuser from xx.xxx.xxx.177  port 62627 ssh2: RSA a3::d7
Jan 18 21:47:03 myhost sshd[2514]: pam_unix(sshd:session): session opened for user myuser by (uid=0)
Jan 18 21:47:03 myhost systemd-logind[740]: New session 1 of user myuser.

* Извините, мне пришлось удалить предыдущий вопрос в стеке, так как я случайно разместил несколько IP-адресов в журналах, а затем подумал, что будет лучше, если я повторно отправлю его здесь.