Linux SSH: Restricting Access with AllowUsers
The 'AllowUsers' directive in the Linux sshd_config file is used to specify the users who are allowed to connect to the system via SSH. In this case, 'mybk' and 'user2' are the two users who are allowed to connect.
To configure this, follow these steps:
-
Open the sshd_config file in a text editor. The location of this file varies depending on the Linux distribution, but it is commonly found at /etc/ssh/sshd_config.
-
Search for the 'AllowUsers' directive in the file. If it does not exist, you can add it at the end of the file.
-
Add 'AllowUsers mybk user2' to the line. Replace 'mybk' and 'user2' with the actual usernames you want to allow.
-
Save the changes to the sshd_config file and exit the text editor.
-
Restart the SSH service to apply the changes. The command to restart the SSH service also varies depending on the Linux distribution. It is commonly one of the following commands:
- sudo service ssh restart
- sudo systemctl restart sshd
After these steps, only the specified users (mybk and user2 in this case) will be able to connect to the Linux system via SSH. Other users will be denied access.
原文地址: https://www.cveoy.top/t/topic/Kc6 著作权归作者所有。请勿转载和采集!