Modify ssh default port in CentOS

Source: Internet
Author: User
1. add the port vim/etc/ssh/sshd_config and remove the comment of # Port22 and add the line feed to Port57788. if the comment is added but the comment is modified, we recommend that you keep port 22 first, and then remove the new port. We recommend that you use a large port, such as 10000 ~ More than 65535. Restart the SSH service/etc/init. d/sshdrestart

1. add a port

Vim/etc/ssh/sshd_config

Remove the comment of # Port 22 and add the line feed to Port 57788.

If you want to add but modify the port number, we recommend that you keep port 22 and wait until the new port can be logged on and removed.

We recommend that you use a large port, such as 10000 ~ More than 65535.

Restart the SSH service/etc/init. d/sshd restart

2. enable firewall Port 57788

Vi/etc/sysconfig/iptables

Add-a input-m state? State NEW-m tcp-p tcp? Dport 57788-j ACCEPT

Restart firewall/etc/init. d/iptables restart

3. Shield the default port

It is recommended that the default port 22 be blocked after the new port can be used.

Vi/etc/sysconfig/iptables

In

-A RH-Firewall-1-INPUT-m state? State NEW-m tcp-p tcp? Dport 22-j ACCEPT

Comment out the prefix #

Restart firewall/etc/init. d/iptables restart

Finished.

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.