Linux SSH security policy change ssh port _linux

Source: Internet
Author: User
Tags ssh iptables ssh port

The default SSH port is 22. It is strongly recommended to change to more than 10000. So the probability of others scanning to the port is also greatly reduced. How to modify: # Edit/etc/ssh/ssh_config
Vim/etc/ssh/ssh_config

# under Host *, add a new Port value. Take 18439 as an example:

Port 22

Port 18439

# Edit/etc/ssh/sshd_config (ditto 2 figure)

Vim/etc/ssh/sshd_config

#加入新的 Port Value

Port 22

Port 18439

# After saving, restart the SSH service:

Service sshd Restart

# After setting up the firewall, add the port number inside the firewall

Vim/etc/sysconfig/iptables

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 18439-j ACCEPT

#最后重启防火墙

I've set up two ports here, mainly to prevent errors from being modified so that SSH is no longer logged on.

Change your SSH client (for example: Putty) connection port, test the connection, if the new port can connect successfully, then edit the above two files, delete Port 22 configuration.

If the connection fails, the Port 22 is connected and then reconfigured.

After the port setting is successful, note that you should also remove Port 22 from Iptables, add a new configuration of 18439, and restart Iptables.

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.