SSH 키가 비밀번호를 허용하지만 비밀번호 인증을 계속합니까? (유사한 서버 쌍 사이에서는 발생하지 않고, 한 쌍의 서버 사이에서만 발생함)

SSH 키가 비밀번호를 허용하지만 비밀번호 인증을 계속합니까? (유사한 서버 쌍 사이에서는 발생하지 않고, 한 쌍의 서버 사이에서만 발생함)

나는 이것에 대해 한동안 머리를 긁적였습니다. SFTP용 SSH 키 기반 인증을 설정해야 합니다. 그래서 비밀번호를 사용하여 키 파일을 생성하고 공개 키를 다른 공급업체(제가 관리하지 않는 업체)에 보내 Authorized_keys 파일에 추가했습니다. 이 작업을 수행한 후 다음 명령을 사용하여 서버에 SFTP를 시도했습니다.

sftp -vvv -i /home/xxxuserxxx/.ssh/id_rsa xxxusernamexxx@their_server.org

결과는 다음과 같습니다.

$ sftp -vvv -i /home/xxxuserxxx/.ssh/id_rsa xxxusernamexxx@their_server.org
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "their_server.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to their_server.org [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /home/xxxuserxxx/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xxxuserxxx/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version 9.99 sshlib
debug1: no match: 9.99 sshlib
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to their_server.org:22 as 'xxxusernamexxx'
debug3: hostkeys_foreach: reading file "/home/xxxuserxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type DSA in file /home/xxxuserxxx/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from their_server.org
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],ssh-dss
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-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: [email protected],ssh-dss,[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
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: diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss
debug2: ciphers ctos: aes256-ctr,twofish256-ctr,twofish-ctr,aes128-ctr,twofish128-ctr,3des-ctr,cast128-ctr,aes256-cbc,twofish256-cbc,twofish-cbc,aes128-cbc,twofish128-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: ciphers stoc: aes256-ctr,twofish256-ctr,twofish-ctr,aes128-ctr,twofish128-ctr,3des-ctr,cast128-ctr,aes256-cbc,twofish256-cbc,twofish-cbc,aes128-cbc,twofish128-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: MACs ctos: hmac-sha2-512,hmac-sha2-256,hmac-sha1
debug2: MACs stoc: hmac-sha2-512,hmac-sha2-256,hmac-sha1
debug2: compression ctos: zlib,none
debug2: compression stoc: zlib,none
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-dss
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1036/2048
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-dss SHA256:DB1GiNDCeVZBRU3rM8E3Igontk/9HetMfQ7fT9Trw1U
debug3: hostkeys_foreach: reading file "/home/xxxuserxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type DSA in file /home/xxxuserxxx/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from their_server.org
debug3: hostkeys_foreach: reading file "/home/xxxuserxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type DSA in file /home/xxxuserxxx/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from xxx.xxx.xxx.xxx
debug1: Host 'their_server.org' is known and matches the DSA host key.
debug1: Found key in /home/xxxuserxxx/.ssh/known_hosts:1
debug2: bits set: 1001/2048
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 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 after 4294967296 blocks
debug2: key: /home/xxxuserxxx/.ssh/id_rsa (0x563600ba8e40), explicit
debug3: send packet: type 5
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 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,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 RSA public key: /home/xxxuserxxx/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:6n9VS4JyrsjyhbZ/fpLdQK7hizTdeABG0Lmo5Zp9j8k
debug3: sign_and_send_pubkey: RSA SHA256:6n9VS4JyrsjyhbZ/fpLdQK7hizTdeABG0Lmo5Zp9j8k
Enter passphrase for key '/home/xxxuserxxx/.ssh/id_rsa': 
<<<I entered the passphrase here>>>
debug3: send packet: type 50
debug3: receive packet: type 51
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
xxxusernamexxx@their_server.org's password: 

이유를 알려주지 않고 비밀번호를 전부 건너뛰고 비밀번호 인증을 진행하는 것을 볼 수 있습니다. 그런 다음 id_rsa 및 id_rsa.pub 파일을 다른 서버, 동일한 서브넷 및 동일한 방화벽 규칙에 복사했으며 sftp 프로세스가 제대로 작동했습니다. 사용자 이름, 디렉터리 권한 및 sshd 구성도 동일합니다. 출력은 다음과 같습니다.

$ sftp -vvv -i /home/xxxuserxxx/.ssh/id_rsa xxxusername@their_server.org
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "their_server.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to their_server.org [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /home/xxxuserxxx/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xxxuserxxx/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version 9.99 sshlib
debug1: no match: 9.99 sshlib
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to their_server.org:22 as 'xxxusernamexxx'
debug3: hostkeys_foreach: reading file "/home/xxxuserxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type DSA in file /home/xxxuserxxx/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from their_server.org
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],ssh-dss
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-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: [email protected],ssh-dss,[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
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: diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss
debug2: ciphers ctos: aes256-ctr,twofish256-ctr,twofish-ctr,aes128-ctr,twofish128-ctr,3des-ctr,cast128-ctr,aes256-cbc,twofish256-cbc,twofish-cbc,aes128-cbc,twofish128-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: ciphers stoc: aes256-ctr,twofish256-ctr,twofish-ctr,aes128-ctr,twofish128-ctr,3des-ctr,cast128-ctr,aes256-cbc,twofish256-cbc,twofish-cbc,aes128-cbc,twofish128-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: MACs ctos: hmac-sha2-512,hmac-sha2-256,hmac-sha1
debug2: MACs stoc: hmac-sha2-512,hmac-sha2-256,hmac-sha1
debug2: compression ctos: zlib,none
debug2: compression stoc: zlib,none
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-dss
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1047/2048
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-dss SHA256:DB1GiNDCeVZBRU3rM8E3Igontk/9HetMfQ7fT9Trw1U
debug3: hostkeys_foreach: reading file "/home/xxxuserxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type DSA in file /home/xxxuserxxx/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from their_server.org
debug3: hostkeys_foreach: reading file "/home/xxxuserxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type DSA in file /home/xxxuserxxx/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from xxx.xxx.xxx.xxx
debug1: Host 'their_server.org' is known and matches the DSA host key.
debug1: Found key in /home/xxxuserxxx/.ssh/known_hosts:2
debug2: bits set: 959/2048
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 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 after 4294967296 blocks
debug2: key: /home/xxxuserxxx/.ssh/id_rsa (0x55fe2bcde740), explicit
debug3: send packet: type 5
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 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,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 RSA public key: /home/xxxuserxxx/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:6n9VS4JyrsjyhbZ/fpLdQK7hizTdeABG0Lmo5Zp9j8k
debug3: sign_and_send_pubkey: RSA SHA256:6n9VS4JyrsjyhbZ/fpLdQK7hizTdeABG0Lmo5Zp9j8k
Enter passphrase for key '/home/xxxuserxxx/.ssh/id_rsa': 
<<<I entered the passphrase here>>>
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to their_server.org ([xxx.xxx.xxx.xxx]:22).
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env HOSTNAME
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env HISTSIZE
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SSH_TTY
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug3: Ignored env JAVA_HOME
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env HISTCONTROL
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env OLDPWD
debug3: Ignored env _
debug1: Sending subsystem: sftp
debug2: channel 0: request subsystem confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 16384 rmax 35840
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: subsystem request accepted on channel 0
debug2: Remote version: 3
Connected to their_server.org.
debug3: Sent message fd 3 T:16 I:1
debug3: SSH_FXP_REALPATH . -> /Home/xxxusernamexxx size 0
sftp> 

따라서 해당 시스템에서 실행할 수 있습니다. 또한 ssh-key를 사용하여 내 서버에서 다른 서버(xxxuserxxx 사용)에 로그인하는 것을 테스트했는데 제대로 작동했으므로 내 측에서는 구성하지 않았습니다. 이는 내 서버와 their_server.org 사이에만 발생하는 문제인 것 같습니다. 로그에 액세스할 수 없으며 회사에서는 문제 해결에 별로 도움이 되지 않습니다. 새 키 생성을 포함하여 제가 생각할 수 있는 모든 것을 시도했습니다. 어떤 아이디어라도 도움이 될 것입니다!

관련 정보