Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to deny access to a single user (test1 ) from ip - So this is what I have added the following line in /etc/ssh/sshd_config

DenyUsers test1@

Then have restarted sshd after making changes to the sshd_config. But after this change in the conf file all the users from that IP after getting a permission denied message. Instead I want to deny access only to a single user 'test1'.

sshd_config man pages states as follows:


This keyword can be followed by a list of user name patterns, separated by spaces. Login is disallowed for user names that match one of the patterns. Only user names are valid; a numerical user ID is not recognized. By default, login is allowed for all users. If the pattern takes the form USER@HOST then USER and HOST are separately checked, restricting logins to particular users from particular hosts. The allow/deny directives are processed in the following order: DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups.

I am particularly intereted in restricting only the user 'test1' from the above IP. But I am ok with the user doing a login from a diffirent IP. Anything I am missing here ?

share|improve this question
DenyUsers test1@ Are you sure that is the address that the destination server "sees"? Sometimes the connection comes over another interface or a NAT. – user247322 Oct 9 '14 at 11:53

Thats the way it works, I've just tested it myself on a RHEL6 server here, all I added to was:



And now only sirch is unable to login only from that address. Sirch can log in from other addresses, and everyone else can log in from all addresses including that one.

Is it possible something else changed?

share|improve this answer
Hi, I have the same setup but it does not work like that for me. How can I debug it further ? Is the user (sirch) been made part of any other group or settings ? Or should the DenyUsers be put in an apt place in the conf file ? – linxsaga Jun 14 '12 at 11:42
Watch /var/log/secure `Jun 14 13:35:17 rhel6svr sshd[10143]: User sirch from not allowed because listed in DenyUsers – Sirch Jun 14 '12 at 12:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.