사용자가 "AllowUsers" 목록에 있으면 SSH 액세스가 거부됩니다.

사용자가 "AllowUsers" 목록에 있으면 SSH 액세스가 거부됩니다.

나는 내 직장에서 Linux 상자의 관리를 물려받았는데, 그 관리는 현재 사망한 동료가 설정했습니다. 최근에 나는 시스템에 새로운 사용자를 추가하고 그녀에게 컴퓨터를 사용하는 대부분의 사람들이 액세스하는 방식으로 SSH 액세스 권한을 부여하려고 했습니다. 지금은 회사에 갈 수 없어요

일어나는 일은 다음과 같습니다.

scmb-bkobe03m:~ xzhang$ ssh -v -X -p 22 arwen@myServer
OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to myServer [152.98.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /Users/xzhang/.ssh/identity type -1
debug1: identity file /Users/xzhang/.ssh/id_rsa type 1
debug1: identity file /Users/xzhang/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze2
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
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: Host '[myServer]:22' is known and matches the RSA host key.
debug1: Found key in /Users/xzhang/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/xzhang/.ssh/identity
debug1: Offering public key: /Users/xzhang/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/xzhang/.ssh/id_dsa
debug1: No more authentication methods to try.

물론 이제 그녀의 공개 SSH 키를 authorized_keys파일에 추가했습니다. 그래서 /var/log/auth.log를 보고 찾았습니다.

Jan  7 11:37:12 sauron sshd[5002]: User arwen from myClientMachine not allowed because not listed in AllowUsers

내가 그녀를 다음에 추가했기 때문에 그것은 재미있다 AllowUsers:

daniel@sauron:~$ sudo more /etc/ssh/sshd_config | grep AllowUsers
AllowUsers jonathan daniel rafael simon thomas li arwen

여기서 어디로 가야할지 모르겠습니다. 받는 사람이 있나요?

답변1

SSH 서버를 다시 시작했거나 SIGHUP을 보내 구성 파일을 다시 로드하라고 지시한 것이 확실하다면...

아마도 섹션 AllowUsers에 있을까요 Match? 이전 지시문이 있는 경우 MatchJonathan, Alvin 및 기타 사용자는 특정 상황에서만 허용될 수 있습니다.


Match localhost PasswordAuthentication yes

# Whitelist users who may ssh in
AllowGroups admin
AllowUsers jonathan daniel rafael simon thomas li arwen

(이 설명은 오해의 소지가 있습니다. 이 지시문 AllowGroupsAllowUserslocalhost에 로그인할 때만 적용됩니다. 이 Match localhost지시문은 이 지시문 아래로 이동해야 합니다.)

답변2

Ubuntu를 사용하는 경우 나와 동일한 문제가 발생할 수 있습니다. 두 가지 서비스 정의 /etc/init.d/ssh 및 /etc/init/ssh.conf가 있습니다. (이전 스타일)과 같이 서비스를 다시 시작하십시오.

/etc/init.d/ssh restart

아무 작업도 수행하지 않습니다(상태 명령은 아무것도 표시하지 않습니다). Upstart 서비스를 직접 다시 시작하세요.

service ssh restart

이 작업을 수행. 귀하의 경우에는 OS를 다시 시작하는 것이 도움이 되었기 때문에 이것이 문제인 것 같습니다.

또한 사용자가 쉼표가 아닌 공백으로 구분되어 있는지 확인하세요. SSH 데몬은 경고를 표시하지 않습니다.

답변3

무료 자리가 문제일 수 있습니다.

sshd_config 또는 ssh_config에서 AllowGroups 또는 AllowUser가 주석 처리된 경우 이는 SSH 원격 세션에도 적용됩니다. PermitRemotelogin No라고 답한 경우 No를 Yes로 변경하세요.

"문을 주석 처리하고 SSH를 다시 ​​시작하여 다른 것을 변경하기 전에 문제가 있는지 확인할 수도 있습니다. 주석을 달려면 주석 앞에 해시태그를 추가하기만 하면 됩니다.

#AllowGroups Group1 <- made up group
#Allow User User1

AllowGroups Group1
AllowUser User1

사용자 그룹을 확인하여 로그인하려는 사용자 이름이 해당 그룹에 속해 있는지 확인하세요.

vi /etc/group

Group1:100:user1,root, etc <- 여기에 아무것도 나열되어 있지 않으면 거부-허용 문입니다.

sshd_config 또는 ssh_config를 변경한 후에는 ssh를 다시 시작해야 합니다.

svcadm restart ssh

볼만한 다른 장소:

vi /etc/defalut/login
vi /etc/pam.config
vi /etc/sshd_config

관련 정보