Linux SSH Security Policy Change ssh port

Source: Internet
Author: User
Tags ssh port

The default ssh port is 22. We strongly recommend that you change it to 10000 or above. In this way, the chances of other users scanning ports are also greatly reduced. Modification Method: # edit/etc/ssh/ssh_config
Vim/etc/ssh/ssh_config

# Add a new port value under host. Take 18439 as an example:

Port 22

Port 18439

# Edit/etc/ssh/sshd_config (same as Figure 2 above)

Vim/etc/ssh/sshd_config

# Add a new port value

Port 22

Port 18439

# Restart the SSH service after saving:

Service sshd restart

# Add the port number in the firewall after setting the Firewall

Vim/etc/sysconfig/iptables

-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 18439-J accept

# Restart the Firewall

Here, I set two ports to prevent SSH from being unable to be accessed again due to modification errors.

Change the connection port of your SSH client (for example, Putty) and test the connection. If the new port can be connected successfully, edit the above two files and delete the configuration of port 22.

If the connection fails, use port 22 to connect and then reconfigure it.

After the port is successfully set, note that port 22 should be deleted from iptables, port 18439 of the new configuration should be added, and iptables should be restarted.

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.