UsePAM이 "no"로 설정된 경우 SSH 공개 키 인증이 실패합니다.


19

비밀번호 인증을 사용 중지하려면 다음 값을 설정했습니다. sshd_config

ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no

개인 키로 로그인하려고하면

Permission denied (publickey).

그런 다음로 변경 UsePAM하면 yes개인 키를 사용하여 로그인 할 수 있습니다. 왜?

OSX에서 Ubuntu 12.04 64 비트 호스트에 연결하고 있습니다

ssh -i ~/.ssh/deploy -l deploy localhost -p 2222 -v

자세한 ssh출력은 다음과 같습니다.

OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/<user>/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /Users/<user>/.ssh/deploy type 1
debug1: identity file /Users/<user>/.ssh/deploy-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
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
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 50:db:75:ba:11:2f:43:c9:ab:14:40:6d:7f:a1:ee:e3
debug1: Host '[localhost]:2222' is known and matches the RSA host key.
debug1: Found key in /Users/<user>/.ssh/known_hosts:2
debug1: ssh_rsa_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
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/<user>/.ssh/key1
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/<user>/.ssh/deploy
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

디버그 모드에서 sshd를 실행하고 생성 된 로그를 확인 했습니까?
Michael Hampton

더 많은 로그가 필요합니다. Fedora 17을 사용하여 VM에서 상황을 복제하여 저에게 효과적이었습니다.
Scott Pack

답변:


15

PAM (Pluggable Authentication Module)이 없으면 인증을 위해 더 복잡한 ssh 구성이 필요합니다. 실제로 이것을 찾고 있습니다.

# grep Password /etc/ssh/sshd_config 
PermitEmptyPasswords no
PasswordAuthentication no

비밀번호 로그인이 비활성화됩니다. 공개 키 설정이 올바르게 설정되었는지 확인하십시오.


4
이것은 사실이 아닙니다. 사실, 많은 가이드가 설정하는 것이 좋습니다 ChallengeResponseAuthentication, PasswordAuthentication그리고 UsePAM모든 no에만 공개 키 인증을 사용. 나는 그런 환경에서 일한 적이 없으므로 아직 작동하지 않는 이유를 쉽게 알 수 없습니다.
Scott Pack

3
그래서 내가 찾은 모든 가이드가 그것을했기 때문에 처음에 아니오로 설정했습니다!
Erik Aigner

나는 정정 될 것이다. 맞아요, 스캇 pam_unix를 사용하지 않으려면 pam_nologin을 구성하거나 루트 액세스를 허용해야합니다. www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9
Stephan

9

사용자 계정이 잠겨 있습니까? 사용자 계정을 잠금 해제 할 수 있습니다

passwd -u username

또는 사용자 계정을 잠그지 만 PAM을 활성화하십시오.

ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM yes

1
또한 passwd -u사용자가 빈 암호를 가지고 있으면 실패합니다. echo username:$(head -c12 /dev/urandom |base64) |chpasswd임의의 유효한 비밀번호를 설정하는 데 사용 합니다.
temoto

usermod -p '*' username이 세 가지를 모두 "no"로 설정하고 "username"은 공개 암호 인증을 사용하여 연결 암호를 설정하지 않고도 연결할 수 있습니다.
David
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.