Modify SSH port and disable root remote login under centos 6.5

  • 2020-05-17 07:33:12
  • OfStack

preface

We all know that the default port of SSH is 22, but for security reasons, we need to modify the SSH port of the server and disable root remote login.

Through the following steps, we passed the edit /etc/ssh/sshd_config , change the port to 10089, disable root remote login, add firewall rules for the new port, and delete the rules for the default port.

Note: 1. Use root user to perform the following steps; 2. Verify only under CentOS 6.5.

Modify the port


vi /etc/ssh/sshd_config
Port 10089 # The port number 
PermitRootLogin no #  ban root ssh

Open firewall rules for new ports


iptables -I INPUT 4 -m state --state NEW -p tcp --dport 10089 -j ACCEPT
service iptables save
service iptables reload

Remove the rule for port 22


iptables -D INPUT $RULE_LINE_NUMBER
service iptables save
service iptables reload

$RULE_LINE_NUMBER Can be achieved by iptables -L -n �line-number To view the

conclusion

The above is all about centos6.5, which is to modify SSH port and disable root remote login. I hope the content of this article can bring you some help in your study or work. If you have any questions, you can leave a message to communicate.


Related articles: