Linux How to prohibit root from using ssh to log in and modify ssh port

  
 

1. Disable root user login ssh


#vi /etc/ssh/sshd_config Change PermitRootLogin yes to PermitRootLogin no Restart sshd service#service sshd restart

At this point, using root login will be prompted to refuse:

login as: [email protected]'s password:Access denied

2, modify ssh default port


vi /etc/ssh/sshd_config find #Port 22 section, here is the default use of 22 ports, modified as follows: Port 22Port 7000 then save and exit restart sshd service #service sshd restart

Note: At this time, you can log in using both port 22 and 7000. This avoids the mistake of debugging (such as not adjusting the corresponding firewall policy after adjusting the port), so you cannot use ssh to log in to the server. Use the ssh client and log in to the test with port 7000. After the error, add a comment on Port 22 in the /etc/ssh/sshd_config configuration file and restart the sshd service.
Linux How to prohibit root from using ssh to log in and modify ssh port

Copyright © Windows knowledge All Rights Reserved