ssh localhost: Permission denied (publickey) Ubuntu on WSL2

У меня проблемы с подключением к localhost и отказом в разрешении. Я пробовал все, от root или с помощью sudo.

У меня проблемы с подключением к localhost и отказом в разрешении. Я пробовал все от root или с помощью sudo.

Выполнил следующее:

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
ssh localhost

Как пользователь root я также сделал следующее на случай, если я использую любого пользователя, и каталоги перепутались:

cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
cat /home/shervleradvm/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

Первый раз было потому, что служба не работала. Итак, я выполнил sudo service ssh start
Я также отключил ufw для теста. sudo ufw disable
разрешения на чтение / запись для файлов ключей:

drwx------ 2 shervleradvm shervleradvm 4096 Nov 21 23:15 .
drwxr-xr-x 6 shervleradvm shervleradvm 4096 Nov 21 23:25 ..
-rw-r----- 1 shervleradvm shervleradvm 1146 Nov 21 23:23 authorized_keys
-r-------- 1 root         shervleradvm 2610 Nov 18 13:17 id_rsa
-r-------- 1 shervleradvm shervleradvm  577 Nov 18 13:17 id_rsa.pub
-rw-r--r-- 1 shervleradvm shervleradvm  444 Nov 18 15:05 known_hosts

В файле sshd_config отсутствует следующее, поэтому я добавил и протестировал каждое из них и их комбинации:

  • AllowUsers: добавлено shervleradvm
  • AuthorizedKeysFile: добавлено ~ / .ssh / authorized_keys /root/.ssh/authorized_keys

Затем я немного изменил свой конфигурационный файл после прочтения Пожалуйста, объясните полные шаги, необходимые для установки сервера OpenSSH на Ubuntu , так что теперь он выглядит например:

 # $ OpenBSD: sshd_config, v 1.103 2018/04/09 20:41:22 tj Exp $

 # Это общесистемный файл конфигурации sshd-сервера.  Видеть
 # sshd_config (5) для получения дополнительной информации.

 # Этот sshd был скомпилирован с PATH = / usr / bin: / bin: / usr / sbin: / sbin

 # Стратегия, используемая для параметров в sshd_config по умолчанию, поставляемом с
 # OpenSSH должен указать параметры со значением по умолчанию, где
 # возможно, но оставьте их прокомментированными.  Опции без комментариев имеют приоритет над
 # значение по умолчанию.

Включите /etc/ssh/sshd_config.d/*.conf

 # Порт 22
 #AddressFamily any
 #ListenAddress 0.0.0.0
 #ListenAddress ::

 #HostKey / etc / ssh / ssh_host_rsa_key
 #HostKey / etc / ssh / ssh_host_ecdsa_key
 #HostKey / etc / ssh / ssh_host_ed25519_key

 # Шифры и ключи
 #RekeyLimit по умолчанию нет

 # Логирование
 #SyslogFacility AUTH
 ######################################## EDITED
LogLevel VERBOSE
 ###############################################

 # Аутентификация:
 ###############################################  ############ НОВЫЙ ВЕЩИ ############
AllowUsers shervleradvm root
 ###############################################  ##################################


 #LoginGraceTime 2 мин.
 ######################################### EDITED
PermitRootLogin да
 ###############################################
 #StrictModes yes
 #MaxAuthTries 6
 #MaxSessions 10

PubkeyAuthentication да

 # Ожидается, что .ssh / authorized_keys2 в будущем будет игнорироваться по умолчанию.
 ###############################################  ######################## EDITED
AuthorizedKeysFile ~ / .ssh / authorized_keys /root/.ssh/authorized_keys

 #AuthorizedPrincipalsFile none

 #AuthorizedKeysCommand none
 #AuthorizedKeysCommandUser none

 # Для этого вам также понадобятся ключи хоста в / etc / ssh / ssh_known_hosts
 #HostbasedAuthentication no
 # Измените на yes, если вы не доверяете ~ / .ssh / known_hosts для
 # HostbasedAuthentication
 #IgnoreUserKnownHosts no
 # Не читать пользовательские файлы ~ / .rhosts и ~ / .shosts
 #IgnoreRhosts да

 # Чтобы отключить туннелируемые пароли в открытом виде, измените здесь на no!
Пароль Аутентификация нет
 #PermitEmptyPasswords нет

 # Измените на yes, чтобы включить пароли запроса-ответа (остерегайтесь проблем с
 # некоторые модули и потоки PAM)
ChallengeResponseAuthentication нет

 # Параметры Kerberos
 #KerberosAuthentication no
 #KerberosOrLocalPasswd yes
 #KerberosTicketCleanup да
 #KerberosGetAFSToken no

 # Параметры GSSAPI
 #GSSAPIAuthentication no
 #GSSAPICleanupCredentials да
 #GSSAPIStrictAcceptorCheck yes
 #GSSAPIKeyExchange no

 # Установите значение "да", чтобы включить аутентификацию PAM, обработку учетной записи,
 # и обработка сеанса.  Если это включено, аутентификация PAM будет
 # быть разрешено через ChallengeResponseAuthentication и
 # PasswordAuthentication.  В зависимости от вашей конфигурации PAM,
 # PAM-аутентификация через ChallengeResponseAuthentication может обойти
 # настройка "PermitRootLogin без пароля".
 # Если вы просто хотите, чтобы учетная запись PAM и проверки сеанса выполнялись без
 # PAM аутентификация, затем включите это, но установите PasswordAuthentication
 # и ChallengeResponseAuthentication на «нет».UsePAM да

 #AllowAgentForwarding yes
 ########################################## EDITED
AllowTcpForwarding нет
 ###############################################  ##
 #GatewayPorts no
 ########################################## EDITED
X11 Нет пересылки
 ###############################################  ##
 # X11DisplayOffset 10
 # X11UseLocalhost да
 #PermitTTY да
PrintMotd нет
 #PrintLastLog yes
 #TCPKeepAlive да
 #PermitUserEnvironment no
 # Сжатие отложено
 #ClientAliveInterval 0
 #ClientAliveCountMax 3
 #UseDNS no
 #PidFile /var/run/sshd.pid
 #MaxStartups 10:30: 100
 #PermitTunnel no
 #ChrootDirectory none
 #VersionAddendum none

 # нет пути к баннеру по умолчанию
 ######################################## EDITED
Баннер /etc/issue.net
 ###############################################  ###

 # Разрешить клиенту передавать переменные среды локали
AcceptEnv LANG LC_ *

 # переопределить по умолчанию отсутствие подсистем
Подсистема sftp / usr / lib / openssh / sftp-server

 # Пример переопределения настроек для каждого пользователя
 #Match User anoncvs
 # X11 Нет пересылки
 # AllowTcpForwarding no
 # PermitTTY нет
 # ForceCommand cvs server
 

Я не уверен, что еще я могу попробовать. Я застревал на этом несколько дней, и я прочитал все другие вопросы, касающиеся ssh.

Подробный вывод:

OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/shervleradvm/.ssh/id_rsa type 0
debug1: identity file /home/shervleradvm/.ssh/id_rsa-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_dsa type -1
debug1: identity file /home/shervleradvm/.ssh/id_dsa-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519 type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519_sk type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_xmss type -1
debug1: identity file /home/shervleradvm/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to localhost:22 as 'shervleradvm'
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:RhXPmgq8gMMrSRv7+VlpLb84pRnXi2vDiqdg0EfocK0
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/shervleradvm/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/shervleradvm/.ssh/id_rsa RSA SHA256:WfkneDotRaioAvWLHi+4L0CpHg+EZ8cWMPPGbx/jUXQ
debug1: Will attempt key: /home/shervleradvm/.ssh/id_dsa
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ecdsa
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ed25519
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/shervleradvm/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
***************************************************************************
                         SOME BANNER I HAVE PUT
This computer system is the private property of its owner, whether
individual, corporate or government.  It is for authorized use only.
Users (authorized or unauthorized) have no explicit or implicit
expectation of privacy.
Any or all uses of this system and all files on this system may be
intercepted, monitored, recorded, copied, audited, inspected, and
disclosed to your employer, to authorized site, government, and law
enforcement personnel, as well as authorized officials of government
agencies, both domestic and foreign.
By using this system, the user consents to such interception, monitoring,
recording, copying, auditing, inspection, and disclosure at the
discretion of such personnel or officials.  Unauthorized or improper use
of this system may result in civil and criminal penalties and
administrative or disciplinary action, as appropriate. By continuing to
use this system you indicate your awareness of and consent to these terms
and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the
conditions stated in this warning.
****************************************************************************
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/shervleradvm/.ssh/id_rsa RSA SHA256:WfkneDotRaioAvWLHi+4L0CpHg+EZ8cWMPPGbx/jUXQ
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/shervleradvm/.ssh/id_dsa
debug1: Trying private key: /home/shervleradvm/.ssh/id_ecdsa
debug1: Trying private key: /home/shervleradvm/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/shervleradvm/.ssh/id_ed25519
debug1: Trying private key: /home/shervleradvm/.ssh/id_ed25519_sk
debug1: Trying private key: /home/shervleradvm/.ssh/id_xmss
debug1: No more authentication methods to try.
shervleradvm@localhost: Permission denied (publickey).

ОБНОВЛЕНИЕ 1 : системный журнал в / var / log / syslog только говорит:

Nov 20 01:05:54 ShervLeRad kernel: [35460.503034] WSL2: Performing memory compaction.
Nov 20 01:06:55 ShervLeRad kernel: [35521.519400] WSL2: Performing memory compaction.
Nov 20 01:07:56 ShervLeRad kernel: [35582.535366] WSL2: Performing memory compaction.
Nov 20 01:08:57 ShervLeRad kernel: [35643.552061] WSL2: Performing memory compaction.
Nov 20 01:09:58 ShervLeRad kernel: [35704.567029] WSL2: Performing memory compaction.
Nov 20 01:10:59 ShervLeRad kernel: [35765.582427] WSL2: Performing memory compaction.
Nov 20 01:12:00 ShervLeRad kernel: [35826.597374] WSL2: Performing memory compaction.

auth.log в /var/log/auth.log говорит:

Nov 19 18:48:34 ShervLeRad sudo: shervleradvm : TTY=pts/0 ; PWD=/etc/ssh ; USER=root ; COMMAND=/usr/bin/ssh localhost
Nov 19 18:48:34 ShervLeRad sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Nov 19 18:48:34 ShervLeRad sshd[7026]: Connection closed by authenticating user root 127.0.0.1 port 39490 [preauth]
Nov 19 18:48:34 ShervLeRad sudo: pam_unix(sudo:session): session closed for user root
Nov 19 18:48:37 ShervLeRad sudo: shervleradvm : TTY=pts/0 ; PWD=/etc/ssh ; USER=root ; COMMAND=/usr/bin/vim sshd_config
Nov 19 18:48:37 ShervLeRad sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Nov 19 18:48:51 ShervLeRad sudo: pam_unix(sudo:session): session closed for user root

ОБНОВЛЕНИЕ 2 : Я запустил ssh с -vvv, и результат:

OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolving "localhost" port 22
debug2: ssh_connect_direct
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/shervleradvm/.ssh/id_rsa type 0
debug1: identity file /home/shervleradvm/.ssh/id_rsa-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_dsa type -1
debug1: identity file /home/shervleradvm/.ssh/id_dsa-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/shervleradvm/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519 type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519_sk type -1
debug1: identity file /home/shervleradvm/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/shervleradvm/.ssh/id_xmss type -1
debug1: identity file /home/shervleradvm/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.1 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to localhost:22 as 'shervleradvm'
debug3: hostkeys_foreach: reading file "/home/shervleradvm/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/shervleradvm/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
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
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:RhXPmgq8gMMrSRv7+VlpLb84pRnXi2vDiqdg0EfocK0
debug3: hostkeys_foreach: reading file "/home/shervleradvm/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/shervleradvm/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/shervleradvm/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/shervleradvm/.ssh/id_rsa RSA SHA256:WfkneDotRaioAvWLHi+4L0CpHg+EZ8cWMPPGbx/jUXQ
debug1: Will attempt key: /home/shervleradvm/.ssh/id_dsa
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ecdsa
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ed25519
debug1: Will attempt key: /home/shervleradvm/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/shervleradvm/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 53
debug3: input_userauth_banner
***************************************************************************
                            NOTICE TO USERS
This computer system is the private property of its owner, whether
individual, corporate or government.  It is for authorized use only.
Users (authorized or unauthorized) have no explicit or implicit
expectation of privacy.
Any or all uses of this system and all files on this system may be
intercepted, monitored, recorded, copied, audited, inspected, and
disclosed to your employer, to authorized site, government, and law
enforcement personnel, as well as authorized officials of government
agencies, both domestic and foreign.
By using this system, the user consents to such interception, monitoring,
recording, copying, auditing, inspection, and disclosure at the
discretion of such personnel or officials.  Unauthorized or improper use
of this system may result in civil and criminal penalties and
administrative or disciplinary action, as appropriate. By continuing to
use this system you indicate your awareness of and consent to these terms
and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the
conditions stated in this warning.
****************************************************************************
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-with-mic,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 public key: /home/shervleradvm/.ssh/id_rsa RSA SHA256:WfkneDotRaioAvWLHi+4L0CpHg+EZ8cWMPPGbx/jUXQ
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/shervleradvm/.ssh/id_dsa
debug3: no such identity: /home/shervleradvm/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/shervleradvm/.ssh/id_ecdsa
debug3: no such identity: /home/shervleradvm/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/shervleradvm/.ssh/id_ecdsa_sk
debug3: no such identity: /home/shervleradvm/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /home/shervleradvm/.ssh/id_ed25519
debug3: no such identity: /home/shervleradvm/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/shervleradvm/.ssh/id_ed25519_sk
debug3: no such identity: /home/shervleradvm/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/shervleradvm/.ssh/id_xmss
debug3: no such identity: /home/shervleradvm/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
shervleradvm@localhost: Permission denied (publickey).

ОБНОВЛЕНИЕ 3 :

Я только что попробовал ssh -i id_rsa localhost из каталога ~ / .ssh пользователя shervleradvm, чтобы попытаться определить private_key использовать. Это не сработало. Итак, я сделал touch config && vim config , затем определил закрытый ключ для localhost:

Host localhost
        HostName localhost
        User shervleradvm
        IdentityFile ~/.ssh/id_rsa

и затем запустил ssh localhost . Ошибка сохраняется.

ОБНОВЛЕНИЕ 4 : Я изменил владельца закрытого ключа на shervleradvm и дал следующие разрешения:

-rw------- 1 shervleradvm shervleradvm 2610 Nov 18 13:17 id_rsa
-r-------- 1 shervleradvm shervleradvm  577 Nov 18 13:17 id_rsa.pub

не помогло.

2
задан 24 November 2020 в 17:41

2 ответа

Я потратил день на поиск в Google, и наконец он заработал.

Цитируется из вашего журнала -vvv :

debug1: Предлагает открытый ключ: / home /shervleradvm/.ssh/id_rsa RSA SHA256: WfkneDotRaioAvWLHi + 4L0CpHg + EZ8cWMPPGbx / jUXQ debug3: отправить packet: type 50 debug2: мы отправили пакет публичного ключа, ждем ответа debug3: получить пакет: тип 51

Это показывает, что ваш открытый ключ отправлен, но « пакет приема: тип 51 » означает проблемы с разрешениями на стороне сервера (WSL в вашем case), когда в вашем sshd_config включен строгий режим.

Внутри WSL в вашей домашней папке очень тщательно установите права доступа:

  • Владелец и группа должны быть установлены для вашего пользователя в ~ / .ssh и ее файлы.
  • Папка ~ / .ssh должна иметь значение 700 / drwx ------
  • Файл authorized_keys должен иметь значение 711 / -rwx - x - x
  • Файлы *. pub должны иметь значение 644 / -rw-r - r -
  • Все остальные файлы должны иметь значение 600 / -rw -------

Вне WSL в каталоге .ssh вашей домашней папки Файл config должен выглядеть так:

Host localhost
  HostName localhost
  User shervleradvm
  PubkeyAuthentication yes

Параметр IdentityFile ~ / .ssh / id_rsa не нужен.

1
ответ дан 3 January 2021 в 22:48
-r-------- 1 root         shervleradvm 2610 Nov 18 13:17 id_rsa

Он принадлежит пользователю root и доступен для чтения только root.

Выполнить

sudo chown shervleradvm ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
0
ответ дан 3 January 2021 в 22:48

Другие вопросы по тегам:

Похожие вопросы: