Super User is a question and answer site for computer enthusiasts and power users. 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

Can I restrict the number of ssh connections to my Linux box - by username or by ip or both?

share|improve this question
You should probably have a more descriptive title so that people know what you are asking at a glance. – MDMarra Sep 14 '10 at 13:53

To allow login only some users you can use AllowUsers keyword in /etc/ssh/sshd_config. To restrict a number of ssh connections You can use MaxSessions keyword.

For example:

AllowUsers jack joe
MaxSessions 5

From manual:

AllowUsers This keyword can be followed by a list of user name patterns, separated by spaces. If specified, login is allowed only 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 partic- ular hosts. The allow/deny directives are processed in the following order: DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups.

share|improve this answer

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.