SSH 클라이언트는 키를 무시하고 비밀번호에 의존합니다.

SSH 클라이언트는 키를 무시하고 비밀번호에 의존합니다.

다음 줄을 사용하여 내 서버에 연결합니다.

ssh -v -i C:\ssh\flyingclub_id_rsa -p 222[이메일 보호됨]

열쇠를 찾은 것 같습니다.

Windows 클라이언트:

OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2                             
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 222.     
debug1: Connection established.                                       
debug1: identity file C:\\ssh\\flyingclub_id_rsa type 0               
debug1: identity file C:\\ssh\\flyingclub_id_rsa-cert type -1         
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1          
debug1: Remote protocol version 2.0, remote software version
OpenSSH_8.6                                                           
debug1: match: OpenSSH_8.6 pat OpenSSH* compat 0x04000000             
debug1: Authenticating to xxx.xxx.xxx.xxx:222 as 'webserver'          
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:
<implicitcompression: none                                          
debug1: kex: client->server cipher: [email protected] MAC:
<implicitcompression: none                                          
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY                             
debug1: Server host key: ecdsa-sha2-nistp256
SHA256:EkbhtzWxf8m+y9GitYbTF8IlAZshqVLd8W4mGYs5dvg                    
debug1: Host '[xxx.xxx.xxx.xxx]:222' is known and matches the ECDSA
host key.                                                             
debug1: Found key in C:\\Users\\Chris/.ssh/known_hosts:2              
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: pubkey_prepare: ssh_get_authentication_socket: No such file or
directory                                                             
debug1: Will attempt key: C:\\ssh\\flyingclub_id_rsa RSA
SHA256:cdbgYmSzYqETRvqvw6Kb6NV+rF6gcmdWiRuami4F8eY explicit           
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],[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received                              
debug1: Authentications that can continue:
publickey,gssapi-keyex,gssapi-with-mic,password                       
debug1: Next authentication method: publickey                         
debug1: Offering public key: C:\\ssh\\flyingclub_id_rsa RSA
SHA256:cdbgYmSzYqETRvqvw6Kb6NV+rF6gcmdWiRuami4F8eY explicit           
debug1: Authentications that can continue:
publickey,gssapi-keyex,gssapi-with-mic,password                       
debug1: Next authentication method: password                          
debug1: read_passphrase: can't open /dev/tty: No such file or
directory                                                             
[email protected]'s password:

리눅스 클라이언트:

ssh -vv -i /home/ns2/.ssh/flyingclub_id_rsa -p 222 [email protected];
OpenSSH_8.4p1 Ubuntu-5ubuntu1, OpenSSL 1.1.1j  16 Feb 2021
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: resolve_canonicalize: hostname xxx.xxx.xxx.xxx is address
debug2: ssh_connect_direct
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 222.
debug1: Connection established.
debug1: identity file /home/ns2/.ssh/flyingclub_id_rsa type 0
debug1: identity file /home/ns2/.ssh/flyingclub_id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4p1 Ubuntu-5ubuntu1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.6
debug1: match: OpenSSH_8.6 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to xxx.xxx.xxx.xxx:222 as 'webserver'
debug1: SSH2_MSG_KEXINIT sent
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],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[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-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr
debug2: ciphers stoc: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
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
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:EkbhtzWxf8m+y9GitYbTF8IlAZshqVLd8W4mGYs5dvg
debug1: Host '[xxx.xxx.xxx.xxx]:222' is known and matches the ECDSA host key.
debug1: Found key in /home/ns2/.ssh/known_hosts:3
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/ns2/.ssh/flyingclub_id_rsa RSA SHA256:b1i1axYBeTcJsY+RvspQkMhrea4dquFHOzvsjihKgZQ explicit
debug2: pubkey_prepare: done
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],[email protected]>
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
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_1000)


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


debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Offering public key: /home/ns2/.ssh/flyingclub_id_rsa RSA SHA256:b1i1axYBeTcJsY+RvspQkMhrea4dquFHOzvsjihKgZQ explicit
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
[email protected]'s password:

무슨 문제가 있는지 잘 모르겠습니다.

내 키는 클라이언트에서 ssh-keygen을 사용하여 생성되고 Fedora의 조종석을 사용하여 복사됩니다.

내가 잘못된 키를 생성했나요?


서버 로그를 지적해 주셔서 감사합니다.

Journalctl -u sshd |tail -100

Authentication refused: bad ownership or modes for directory ...

답변1

답변의 로그는 설명이 매우 필요합니다. 어떤 디렉터리인지 확인하기 위해 전체 출력을 붙여넣지는 않았지만 서버의 .ssh 디렉터리 또는 Authorized_keys 파일에 대한 잘못된 권한이 있을 수 있습니다.

홈 또는 ~/.ssh 디렉토리에 그룹 쓰기 권한이 있는 경우 SSH는 이를 좋아하지 않습니다. 홈 디렉토리는 본인만 작성할 수 있습니다. ~/.ssh는 700, Authorized_keys는 600이어야 합니다.

chmod go-w /home/user
chmod 700 /home/user/.ssh
chmod 600 /home/user/.ssh/authorized_keys

/home/user를 시스템의 실제 사용자로 바꾸십시오. 명령에서 이 사용자는 다음과 같아야 합니다.네트워크 서버. 또한 .ssh 디렉터리와 Authorized_keys 파일의 사용자 및 그룹도 올바른지 확인하세요.

관련 정보