1. Modify SSH remote default port 22
Assuming that the remote port is to be modified to 10022, modify the following two configuration files
Find #port 22, add Port 10022 below
Then restart the sshd
# Service Sshd Restart
2. Disable root login via SSH
Find Permitrootlogin, change the following yes to No, the previous comment # is canceled, so root cannot log in remotely!
You can log in with a regular account and use the command SU root to switch to the root account when using root
3. Restrict SSH access to users
Suppose we just root,user1 and user2 users can use the system via SSH to add to the Sshd_config configuration file
Allowusers Root user1 User2
4. Configure idle time-out interval
Users can log on to the server via SSH, and you can set an idle time-out interval.
Open the Sshd_config configuration file, set as follows.
The above example sets an idle time-out interval of 600 seconds, or 10 minutes,
After this time, the idle user will be kicked out automatically (can be understood as exit login/Logoff).
5. Limit only one IP to telnet to the server
Vim/etc/hosts.deny #在其中加入sshd: All
Vim/etc/hosts.allow #在其中进行如下设置: sshd:192.168.1.1 # (only allow 192.168.1.1 this IP telnet server)
Last restart SSH service:/etc/init.d/sshd restart
Modify a normal user with root privileges
1) Enter Super User mode. That is, enter "Su-", the system will let you enter the super user password, enter the password and enter the Super User mode. (Of course, you can also use root directly)
2) Add Write permission to the file. That is, enter the command "chmod u+w/etc/sudoers".
3) Edit the/etc/sudoers file. That is, enter the command "Vim/etc/sudoers", enter "I" into the editing mode, find this line: "Root all= (All) all" in the following add "XXX all= (All) all" (Here xxx is your user name), Then save (just press the ESC key and enter ": Wq") to exit.
4) Revoke the Write permission of the file. This is the input command "chmod u-w/etc/sudoers".
This article is from the "lake and Laughter" blog, please make sure to keep this source http://hashlinux.blog.51cto.com/9647696/1788393
CentOS Remote Management security settings