암호가 설정되지 않은 공개 키에 대해 암호를 요청하는 SSH

암호가 설정되지 않은 공개 키에 대해 암호를 요청하는 SSH

한동안 내 서버에서 공개 키 인증을 사용해 왔지만 연결을 시도하는 새 '클라이언트'에 문제가 발생했습니다.깃허브. 내 권한이 올바르게 설정되었는지 확인하고 github에 대한 새 키를 생성했는지 확인하기 위해 많은 스레드를 읽었습니다. 내가 직면한 문제는 암호 문구를 설정하지 않았음에도 ssh가 암호 문구를 요구한다는 것입니다. 암호 문구를 입력하지 않았음을 100% 확신하기 위해 키를 다시 만들었습니다.

SSH -vvv다음과 같은 관련 출력을 제공합니다.

debug1: Offering public key: /home/me/.ssh/github.pub
debug2: we sent a publickey packet, wait for reply
debug3: Wrote 368 bytes for a total of 1495
debug1: Remote: Forced command: gerve mygithubusername c3:71:db:34:98:30:6d:c2:ca:d9:51:a8:c6:1b:fc:f7
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp c3:71:db:34:98:30:6d:c2:ca:d9:51:a8:c6:1b:fc:f7
debug3: sign_and_send_pubkey
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/me/.ssh/github.pub': 

왜 그런 말이 나오는지 검색해봤는데PEM_read_PrivateKey실패했지만 해결책을 찾을 수 없습니다.

나는 대리인이나 아무것도 사용하지 않습니다. ~/.ssh/config 파일을 다음과 유사하게 구성합니다.

Host github
Host github.com
Hostname github.com
User git
PubkeyAuthentication yes
IdentityFile /home/me/.ssh/github.pub

미리 감사드립니다.

답변1

개인을 가리키는 IdentityFile옵션을 사용할 때 ,~/.ssh/config대중이 아니라, 열쇠.

에서 man ssh_config:

신원 파일
사용자의 DSA, ECDSA 또는 DSA 인증 ID를 읽는 파일을 지정합니다. 기본값은 프로토콜 버전 1의 경우 ~/.ssh/identity이고 프로토콜 버전 2의 경우 ~/.ssh/id_dsa, ~/.ssh/id_ecdsa 및 ~/.ssh/id_rsa입니다.

따라서 ~/.ssh/config항목은 다음과 같아야 합니다.

Host github.com
Hostname github.com
User git
PubkeyAuthentication yes
IdentityFile /home/me/.ssh/github

답변2

이 문제가 발생했는데 잘라내기 및 붙여넣기 오류였습니다. %키 파일 끝에 단일 기호가 추가되었습니다(따라서 마지막 줄은 -----END RSA PRIVATE KEY-----%). 키의 길이가 잘못되었거나 형식이 잘못되었음을 암시하는 오류나 디버그 정보 또는 기타 항목은 없었지만 ssh는 암호 문구를 요청했습니다.

답변3

제 경우에는 SSH 클라이언트가 ED25519 키를 지원하지 않는다는 것이 문제였습니다. 해결책은 RSA 키를 생성하여 대신 사용하는 것입니다.

이 문제는 다음에서 발생합니다.OpenSSH < 6.5(실행 ssh -V) 및퍼티 < 0.68.

이는 다음 출력에서 ​​볼 수 있습니다 ssh -vvv.

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: [email protected],[email protected],[email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,[email protected]
debug2: kex_parse_kexinit: hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96
debug2: kex_parse_kexinit: hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-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: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,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,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],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,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]

그만큼첫 번째 블록은 클라이언트가 지원하는 것을 설명하고 두 번째 블록은 서버가 지원하는 것을 설명합니다.. 보시다시피, 상단 절반에는 'curve25519'에 대한 언급이 없습니다. 이는 클라이언트가 이를 지원하지 않음을 나타냅니다.

답변4

우리 팀에서는 이런 일이 발생하더라도 로컬에서는 문제가 되지 않습니다. 사용자의 SSH 키 및/또는 액세스가 연결 중인 서버(이 경우 호스팅 플랫폼)에서 올바르게 구성되지 않았습니다. 어떤 이유로 존재하지 않는 SSH 키에 대한 프롬프트가 표시됩니다.

관련 정보