问题原文
原帖链接 · Johannes · CC BY-SA 3.0
I'm trying to modify /etc/ssh/sshd_config on my dedicated debian7 server with both AllowUsers and AllowGroups. However I can't seem get both to work together.
The Setup
- There's a user called
testuser. That user is in a group called
ssh-users:$ groups testuser testuser : testuser ssh-userstestuseris trying to connect viassh testuser@<server_ip>and entering their password.- My
sshd_configcan be found here: http://pastebin.com/iZvVDFKL - I think basically the only changes I made from default was:- to set
PermitRootLogin no - and add two users with
AllowUsers(actual usernames differ on my server)
- to set
service ssh restartis run each time after modifyingsshd_config.
The Problem
testusercan connect when set withAllowUsers:AllowUsers user1 user2 testusertestusercan NOT connect when settingAllowGroupsfor its group:AllowUsers user1 user2 AllowGroups ssh-userswhich results in
Permission denied, please try again.whentestuserenters their password in the ssh password prompt.
The Question
- Does
AllowUsersoverrideAllowGroups? - What's the best way to fix this without manually adding the username to
AllowUsers? Ideally I'd like to be able to just add users to thessh-usersgroup in the future without having to touchsshd_configagain.
已采纳解答
原帖链接 · Jeff-Inventor ChromeOS · CC BY-SA 3.0
Yes, AllowUsers takes precedent over AllowGroups. If specified, only the users that match the pattern specified in AllowUsers may connect to the SSHD instance.
According to sshd_config manpage:
The allow/deny directives are processed in the following order:
DenyUsers,AllowUsers,DenyGroups, and finallyAllowGroups.
So, the solution to your problem is probably to use one or the other, possibly the group access directives if groups are your preferred way to manage users.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
