Modify SSH default port | restrict SSH logon IP addresses | disable ROOT remote logon

Source: Internet
Author: User
Tags ssh port
Modify SSH default port | restrict SSH logon IP addresses | disable ROOT remote logon

1. modify the default SSH Port

 
 
  1. // Modify the configuration file
  2. Vi/etc/ssh/sshd_config
  3. // Modify # Port 22 as follows:
  4. Port 22
  5. Port 888
  6. // Restart the SSH service
  7. /Etc/init. d/sshd restart

In this way, SSH ports 22 and 888 are valid at the same time.

 
 
  1. // Modify the firewall configuration
  2. Vi/etc/sysconfig/iptables
  3. // Enable Port 888
  4. -A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 888-j ACCEPT
  5. // Restart the firewall
  6. /Etc/init. d/iptables restart

Now you can use the SSH tool to connect to Port 888 to test whether the connection is successful. If the connection is successful, edit the sshd_config settings and the firewall port, delete Port22, and restart the ssh service and firewall access rules.

[Tianya PHP blog]-[http://blog.phpha.com]

2. remote ROOT login prohibited

 
 
  1. // Add a user with normal permissions first
  2. Useradd phpha_com
  3. Passwd phpha_com
  4. // Disable ROOT remote SSH login
  5. Vi/etc/ssh/sshd_config
  6. // Modify
  7. PermitRootLogin yes
  8. // Change
  9. PermitRootLogin no
  10. // Restart the sshd service
  11. Service sshd restart

Remote Management: log on to phpha_com as a common user. Then, use su root to switch to the root user and obtain the highest permission.

[Tianya PHP blog]-[http://blog.phpha.com]

3. restrict SSH logon IP addresses

<1> add IP addresses allowed for access

 
 
  1. vi /etc/hosts.allow
  2. sshd: 115.183.13.130

<2> disable all other IP addresses

 
 
  1. vi /etc/hosts.deny
  2. sshd: ALL
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.