이 질문은 이전에 askubuntu.com에서 요청한 적이 있지만 상당히 일반적인 Linux 질문인 것 같아서 여기서 다시 질문합니다.
localhost에 "sshing"하고 권한을 거부하는 데 문제가 있습니다. 나는 루트에서 시작하거나 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
루트로서 사용자 중 하나를 사용하고 디렉토리가 혼란스러울 경우를 대비하여 다음도 수행했습니다.
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 파일에 다음이 누락되어 다음과 그 조합을 추가하고 테스트했습니다.
- 사용자 허용: shervleradvm이 추가됨
- AuthorizedKeysFile: ~/.ssh/authorized_keys /root/.ssh/authorized_keys 추가
그런 다음 읽은 후 구성 파일을 약간 변경했습니다.https://askubuntu.com/questions/783843/please-explain-the-complete-steps-involved-in-the-installation-of-openssh-server/783844#783844이제 다음과 같습니다.
# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value. Include /etc/ssh/sshd_config.d/*.conf #Port 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 # Ciphers and keying #RekeyLimit default none # Logging #SyslogFacility AUTH ########################################## EDITED LogLevel VERBOSE ################################################## # Authentication: ############################################################## NEW STUFF ############ AllowUsers shervleradvm root ##################################################################################### #LoginGraceTime 2m ########################################### EDITED PermitRootLogin yes ################################################## #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 PubkeyAuthentication yes # Expect .ssh/authorized_keys2 to be disregarded by default in future. ########################################################################### EDITED AuthorizedKeysFile ~/.ssh/authorized_keys /root/.ssh/authorized_keys #AuthorizedPrincipalsFile none #AuthorizedKeysCommand none #AuthorizedKeysCommandUser nobody # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # HostbasedAuthentication #IgnoreUserKnownHosts no # Don't read the user's ~/.rhosts and ~/.shosts files #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! PasswordAuthentication no #PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes #GSSAPIStrictAcceptorCheck yes #GSSAPIKeyExchange no # 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 #AllowAgentForwarding yes ############################################ EDITED AllowTcpForwarding no #################################################### #GatewayPorts no ############################################ EDITED X11Forwarding no #################################################### #X11DisplayOffset 10 #X11UseLocalhost yes #PermitTTY yes PrintMotd no #PrintLastLog yes #TCPKeepAlive yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #UseDNS no #PidFile /var/run/sshd.pid #MaxStartups 10:30:100 #PermitTunnel no #ChrootDirectory none #VersionAddendum none # no default banner path ########################################## EDITED Banner /etc/issue.net ##################################################### # Allow client to pass locale environment variables AcceptEnv LANG LC_* # override default of no subsystems Subsystem sftp /usr/lib/openssh/sftp-server # Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # PermitTTY no # 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: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] 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,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
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의 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.
/var/log/auth.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: -vvv를 사용하여 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 *
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: [email protected],[email protected],[email protected],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,[email protected],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: [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],[email protected],[email protected],ssh-ed25519,[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],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,[email protected],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: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
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: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] 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,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
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
방금 shervleradvm 사용자의 ~/.ssh 디렉토리에서 사용할 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
도움이 안돼.
답변1
Authorized_keys에는 600이 아닌 644 권한이 있어야 합니다.
클라이언트는 id_rsa에서 sha256을 제공하지만 서버는 이를 허용하지 않는 것 같습니다. sshd.conf에서 LogLevel을 높인 후 sshd를 다시 시작하고 다시 로그인한 후 서버 로그를 확인하세요. 또한 ssh-keygen을 사용하여 id_rsa 및 Authorized_keys에 대한 .ssh 디렉터리를 확인해야 합니다.비교하다각각의 sha256 지문은 다음과 일치해야 합니다.
ssh-keygen -l -f .ssh/authorized_keys
ssh-keygen -l -f .ssh/id_rsa
(키의 ASCII 아트 표현을 원할 경우 위에 -v를 추가할 수 있습니다).
또한 .ssh와 그 안에 있는 파일의 권한과 소유권을 확인하세요. 이 디렉터리는 700으로 설정되어야 하며 모든 *.pub, config, Known_hosts 및 Authorized_keys는 644로 설정되어야 합니다. 모든 개인 키는 600으로 설정되어야 합니다.