rsa 키를 사용하여 SSH 터널을 통해 로그인하면 여전히 비밀번호 프롬프트가 표시됩니다.

rsa 키를 사용하여 SSH 터널을 통해 로그인하면 여전히 비밀번호 프롬프트가 표시됩니다.

동적 IP 주소가 있는 랩톱 두 대(호스트 A와 호스트 C)와 데스크톱 한 대(호스트 B)가 있는데 모두 (Ubuntu) Linux를 실행하고 있습니다. 지금은 다음과 같이 호스트 C에서 호스트 A에 액세스할 수 있도록 설정했습니다. 다음 형식의 호스트A에 대한 명령을 사용하여 A에서 C로의 SSH 터널이 있습니다.

autossh -NR 10023:localhost:22 [email protected]

저는 autossh 명령이 실제로 발생할 수 있도록 키 페어링을 사용하고 있습니다.

그런 다음 C에서 B로 SSH를 통해 연결한 다음 다음을 사용하여 연결할 수 있습니다.

ssh -p 10023 localhost

비밀번호를 묻는 메시지가 나타나면 들어갈 수 있습니다. 문제가 없습니다.

그러나 A의 보안을 강화하여 로그인에 키가 필요하도록 하고 싶습니다. 그래서 HostB에서 한 쌍의 키를 ssh-keygen으로 생성하고 키 이름을 customkey_rsa로 지정하고 비밀번호를 지정합니다. 그런 다음 customkey_rsa.pub가 공개 키입니다. 이 터널에서 작동하도록 ssh-copy-id를 얻을 수 없으므로 C에서 A에 로그인하고 호스트 B에서 customkey_rsa.pub를 통해 scp합니다. 그런 다음 키를 다음과 같이 추가합니다.

cd .ssh & cat customkey_rsa.pub >> authorized_keys

하지만 이제 로그인을 시도하면 여전히 비밀번호 프롬프트가 표시됩니다. 실제로는 키를 누르는 데까지 성공했지만 아래와 같이 마지막 순간에 포기하는 것처럼 보입니다.

B에서

ssh -v -i customkey_rsa -p 10023 localhost

준다

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Connecting to localhost [127.0.0.1] port 10023.
debug1: Connection established.
debug1: identity file customkey_rsa type 1
debug1: identity file customkey_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA (redacted)
debug1: Host '[localhost]:10023' is known and matches the ECDSA host key.
debug1: Found key in /home/ohnoplus/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: customkey_rsa
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password 
ohnoplus@localhost's password: 

~/.ssh호스트 A에 대한 권한은 700이고 에 대한 권한 .ssh/authorized_keys은 입니다 600.

그래서 내 질문입니다. 이것이 작동하지 않는 이유는 무엇이며 어떻게 해결할 수 있습니까?

내가 본 것 중 도움이 되지 않은 것:

제안 목록을 통해 작업했습니다. 내 시스템에 권한이 올바르게 설정되어 있고 다른 솔루션이 적용되지 않습니다. 공개 키 인증을 사용하는 SSH에서 비밀번호 프롬프트가 계속 표시되는 이유는 무엇입니까?

유사하지만 솔루션이 제공되지 않습니다. rsa 키를 사용하는 ssh에서 비밀번호를 묻습니다.

"authorized_keys2" 파일이 없습니다. .ssh/authorized_keys에도 불구하고 ssh에서 비밀번호를 묻는 메시지가 표시됨

답변1

다음을 추가해야 합니다.

PasswordAuthentication no

sshd_config에 (서버 구성입니다)

관련 정보