unix

How do I restrict ssh access to specific users on my Linux server?

To restrict ssh access on a specific server to a few users, you can update the file /etc/ssh/sshd_config

To allow the users bob, mary, and jane (and root) to access your server, update the /etc/ssh/sshd_config file as follows:

AllowUsers root bob mary jane

This will only allow those 4 users to access the server. Any user not on that list will not be granted access.

There are also several alternatives such as AllowGroups which can be used to grant specific groups access. Other alternatives allow you to prevent specific users or groups from accessing the server.

Those directives are:

DenyUsers baduser1

DenyGroups formeradmins

1 Comment

1 Comment

  1. protectaid

    September 9, 2010 at 5:38 pm

    I’m definitely going to bookmark you! Thank you for your info.

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top