Linux/centos to modify the SSH default port number

Source: Internet
Author: User
Tags ssh port

In Linux, the default SSH port number is 22, because this is known as the port number, once the intruder to scan the port of 22 port, we immediately know that this is the port number for SSH login, so we need to modify the default port number, Allowing intruders to scan out port numbers does not immediately know what this port does.


1. Modify Firewall port number

Here we are going to change the default SSH port 22 to 2121, so the 2121 port is opened in the firewall

#/sbin/iptables-i input-p TCP--dport 2121-j accept#/etc/rc.d/init.d/iptables save# sed-i "/a input-m state--state New-m tcp-p TCP--dport 22-j accept/d "/etc/sysconfig/iptables# service iptables restart


2. Modify the Sshd_config file

# sed-i ' s/#Port 22/port 2121/'/etc/ssh/sshd_config


3. Restart the SSH service

# Service Sshd Restart


You cannot use port 22 for SSH remote connection at this time, you must use port 2121.






Linux/centos to modify the SSH default port number

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.