Открытые ключи SSH не распознаются - пробовали несколько исправлений

Контекст

  • открытый ключ SSH работал.
  • Я использую xpra для доступа к графическому интерфейсу. (машина в другой комнате, без головы)
  • Я пытался получить приложения-контейнеры докеров с работающим графическим интерфейсом. Я наконец сделал.
  • На следующий день аутентификация с открытым ключом не удалась. Аутентификация по паролю работает
  • единственная команда, которую я использовал для графического интерфейса докера, была xhost

Я пробовал следующее

  • сбросить права доступа к файлам home, .ssh, .ssh как на клиенте, так и на сервере
  • повторно скопированы открытые ключи в ~/.ssh/authorized_keys на сервере
  • перезапускал sshd несколько раз
  • повторно добавлены ключи к ssh-agent на клиенте
  • проверенный файл клиента .ssh/config
  • проверил серверные файлы hosts.allow/.deny
  • отчетность sshd увеличена до DEBUG3
  • отчеты debug2: key not found, Failed public key...
  • Ключи, показанные в auth.log, я не узнаю
  • Я поискал на сервере все файлы author_keys и начал просматривать их все, пока нигде не вижу эти ключи.
  • Я все еще просматриваю те, которые связаны с контейнерами докеров в /var/lib/docker/aufs-bak/...
  • как ни странно, в /media/home./ была копия моей домашней папки. я удалил это

Я не хочу включать аутентификацию по паролю. Я сейчас в полной растерянности.

Мой sshd_config

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel DEBUG3

# Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes


# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

# try to speed up connection with different ciphers, jun24-17
# Ciphers blowfhish-cbc,arcfour

# try to fix nomachine issue, allow password login on LAN, jun24-17
 Match address 192.168.0.0/24
        PasswordAuthentication yes

РЕДАКТИРОВАТЬ: подробная отладка на стороне клиента

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/xxx/.ssh/config
debug1: /Users/xxxssh/config line 9: Applying options for xxx.xxx.xxx.xxx
debug1: /Users/xxx/.ssh/config line 12: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /Users/xxx/.ssh/gpgpu_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/xxx/.ssh/gpgpu_rsa-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_7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to xxx.xxx.xxx.xxx:22 as 'xxx'
debug3: hostkeys_foreach: reading file "/Users/xxx/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/xxx/.ssh/known_hosts:19
debug3: load_hostkeys: loaded 1 keys from xxx.xxx.xxx.xxx
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],zlib,none
debug2: kex_parse_kexinit: [email protected],zlib,none
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: kex_parse_kexinit: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug1: kex: server->client [email protected] <implicit> [email protected]
debug1: kex: client->server [email protected] <implicit> [email protected]
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:j9fYUxFBfiJ7AO21aJiJiCfPOZs1bbkOd8sqeuymBVk
debug3: hostkeys_foreach: reading file "/Users/xxx/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/xxx/.ssh/known_hosts:19
debug3: load_hostkeys: loaded 1 keys from xxx.xxx.xxx.xxx
debug1: Host 'xxx.xxx.xxx.xxx' is known and matches the ECDSA host key.
debug1: Found key in /Users/xxx/.ssh/known_hosts:19
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /Users/xxx/.ssh/gpgpu_rsa (0x7ffcb0e000e0), explicit
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/xxx/.ssh/gpgpu_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

EDIT2: .ssh/config на клиенте. Обратите внимание, я также пробовал без явного файла идентификации

Host github.com
        ....

Host xxx.xxx.xxx.xxx
        IdentityFile ~/.ssh/gpgpu_rsa

Host *
IdentitiesOnly yes
ForwardX11 yes
ForwardX11Trusted yes

person vv111y    schedule 27.07.2017    source источник
comment
как выглядит ваш файл .ssh/config? попробуйте войти по ssh с -vvv и пройти здесь, чтобы увидеть ошибку   -  person Matx132    schedule 27.07.2017
comment
Проблема заключается в том, чтобы добраться до SSH внутри контейнера или SSH до вашего хост-компьютера?   -  person Tarun Lalwani    schedule 27.07.2017
comment
@Tarun Lalwani Хост-машина   -  person vv111y    schedule 27.07.2017
comment
На вашем компьютере выполните cat ~/.ssh/gpgpu_rsa.pub, а на хост-компьютере выполните cat ~/.ssh/authorized_keys, убедитесь, что вы получаете содержимое паба на авторизованных ключах.   -  person Tarun Lalwani    schedule 27.07.2017
comment
что вы подразумеваете под «контентом паба»? Ключи одинаковые   -  person vv111y    schedule 27.07.2017


Ответы (1)


debug1: Offering RSA public key: /Users/xxx/.ssh/gpgpu_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply

Означает, что тест открытого ключа был отправлен, но ключ не был принят сервером. Это может быть по нескольким причинам, но обычно из-за того, что файл ~/.ssh/authorized_keys или родительские каталоги имеют неправильные разрешения. Если вы запустите сервер в режиме отладки, вы сможете отладить, что не так. Или просто опубликуйте разрешения.

person Jakuje    schedule 27.07.2017
comment
У меня есть подробный Auth.log с сервера. Он большой, поэтому я не знаю, что я должен разместить. Я дал лишь краткое изложение. - person vv111y; 27.07.2017
comment
Просто опубликуйте детали последнего подключения. - person Jakuje; 27.07.2017
comment
на обеих машинах закрытые ключи 600, открытые ключи 644, папка .ssh 700, домашняя папка 755 - person vv111y; 27.07.2017
comment
сервер ~/.ssh/authorized_keys 644 - person vv111y; 27.07.2017
comment
хорошо, я поместил сюда вывод auth.log gist.github.com/vv111y/924485eaca3f3a7e8c2c82b5fd8b01e8 - person vv111y; 27.07.2017
comment
Похоже, ваша строка в авторизованных ключах начинается с sh-rsa вместо ssh-rsa (отсутствует s) - person Jakuje; 28.07.2017