.ssh/authorized_keys에도 불구하고 ssh는 여전히 비밀번호를 묻는 메시지를 표시합니다.

.ssh/authorized_keys에도 불구하고 ssh는 여전히 비밀번호를 묻는 메시지를 표시합니다.

ssh username@db2workgoup -n "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"키가 authorized_keys파일 에 저장되어 있는지 발급 하고 확인합니다. 그러나 SSH에는 여전히 비밀번호가 필요합니다. 저희 회사의 다른 서버에서도 같은 방법을 아무런 문제 없이 사용했습니다.

비밀번호 프롬프트 없이 ssh를 도와줄 수 있는 사람이 있나요?

  • OSX에서 SSH
  • SSH를 통해 SUSE 11.2(x86_64)를 엽니다.
  • 홈 디렉터리, .ssh 디렉터리 및 Authorized_keys 파일에 권한이 적용됩니다. 700 이하

/var/log/messagesec 9 11:09:53 db2workgroup automount[3506]: update_negative_cache: key ".user.ini" not found in map.로그인을 시도할 때 입력되는 항목이 있습니다 .

출력은 다음에서 비롯됩니다.ssh -vvv

radek:~ radek$ ssh -vvv root@db2workgroup
OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to db2workgroup [10.0.0.22] port 22.
debug1: Connection established.
debug1: identity file /Users/radek/.ssh/identity type -1
debug1: identity file /Users/radek/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /Users/radek/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /Users/radek/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.2
debug1: match: OpenSSH_5.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
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: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
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 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 133/256
debug2: bits set: 518/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /Users/radek/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 12
debug3: check_host_in_hostfile: filename /Users/radek/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 12
debug1: Host 'db2workgroup' is known and matches the RSA host key.
debug1: Found key in /Users/radek/.ssh/known_hosts:12
debug2: bits set: 509/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
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/radek/.ssh/identity (0x0)
debug2: key: /Users/radek/.ssh/id_rsa (0x0)
debug2: key: /Users/radek/.ssh/id_dsa (0x100123c50)
debug1: Authentications that can continue: publickey,keyboard-interactive
debug3: start over, passed a different list publickey,keyboard-interactive
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: Trying private key: /Users/radek/.ssh/identity
debug3: no such identity: /Users/radek/.ssh/identity
debug1: Trying private key: /Users/radek/.ssh/id_rsa
debug3: no such identity: /Users/radek/.ssh/id_rsa
debug1: Offering public key: /Users/radek/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,keyboard-interactive
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password: 

답변1

과거에 SSH에 비밀번호 없는 설정을 구현하는 방법을 설명하는 몇 가지 튜토리얼을 접했지만 그 중 일부는 잘못되었습니다.

다시 시작하여 각 단계를 확인해 보겠습니다.

  1. 고객으로부터- 키 생성:ssh-keygen -t rsa
  • 공개 및 개인 키( id_rsa.pub및 )는 이 디렉터리 id_rsa에 자동으로 저장됩니다 .~/.ssh/
  • 빈 비밀번호를 사용하면 설정이 더 쉽습니다. 그렇게 하고 싶지 않다면 이 가이드를 따르되 아래 사항도 확인하세요.

  1. 고객으로부터- 공개 키를 다음 위치에 복사합니다.섬기는 사람:ssh-copy-id user@server
  • 클라이언트 공개 키가 다음 위치에 복사됩니다.서버 위치 ~/.ssh/authorized_keys.

  1. 고객으로부터- 서버에 연결:ssh user@server

위의 3단계를 수행한 후에도 여전히 작동하지 않으면 다음을 시도해 보세요.

  • ~/.ssh폴더 권한 확인고객그리고섬기는 사람기계.
  • 체크인/etc/ssh/sshd_config섬기는 사람RSAAuthentication옵션 은 기본적으로 전달되므로 비활성화되지 않았 는지 확인하십시오 .PubkeyAuthenticationUsePAMyes
  • 클라이언트 키를 생성할 때 비밀번호를 입력한 경우 세션 내에서 비밀번호 없는 연결을 시도할 수 있습니다 ssh-agent.ssh-add
  • /var/log/auth.log에서 내용을 확인하세요섬기는 사람키 인증을 전혀 건너뛰는 문제를 파악합니다.

답변2

나는 다음을 기반으로 솔루션을 찾았습니다.Jason Urine의 검토내 질문에.

#AuthorizedKeysFile /usr/NX/home/nx/.ssh/authorized_keys2이는 sshd 구성 파일에서 사용할 수 있습니다 /etc/ssh/sshd_config. 표준 항목을 변경하면 AuthorizedKeysFile .ssh/authorized_keys문제가 해결되었습니다.

답변3

시간이 오래 걸렸어요 /etc/ssh/sshd_config. 마지막으로 다음 파일 권한에 대한 질문이 있습니다.

  • 뿐만 ~/.ssh/authorized_keys아니라.
  • ~/.ssh카탈로그(700)
  • ~카탈로그(700)
ls -la ~/.ssh
total 20
drwx------. 2 user user   76 Aug 10 11:23 .
drwx------. 8 user user 4096 Nov 22  2020 ..
-rw-------. 1 user user 1648 Aug  9 09:57 authorized_keys  
-rw-------. 1 user user 1675 Aug 10 11:22 id_rsa
-rw-r--r--. 1 user user  419 Aug 10 11:22 id_rsa.pub       
-rw-r--r--. 1 user user 1909 Aug 10 11:23 known_hosts 

답변4

키 생성, 서버에 복사본 저장 등의 모든 단계를 완료했다면 ssh-add로컬에서 실행해 볼 수 있습니다.

키 파일의 권한을 확인할 수도 있습니다. 그러나 이 문제는 또 다른 종류의 오류를 발생시킵니다.

관련 정보