Modify the default SSH port number in CentOS/Linux

Source: Internet
Author: User

Modify the default SSH port number in CentOS/Linux

In Linux, the default SSH port number is 22. Because this is a known port number, port 22 is scanned when an intruder scans the port, we can immediately know that this is the port number for SSH Login. Therefore, we need to modify the default port number so that intruders cannot immediately know the port function even if they scan the port number.

CentOS is 6.5

1. Open firewall ports
Here we want to change the default ssh port 22 to 2121, so we need to open port 2121 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

In this case, port 22 cannot be used for ssh remote connection. Port 2121 must be used.

How to Improve the SSH login authentication speed of Ubuntu

Enable the SSH service to allow Android phones to remotely access Ubuntu 14.04

How to add dual authentication for SSH in Linux

Configure the SFTP environment for non-SSH users in Linux

Configure and manage the SSH service on Linux

Basic SSH tutorial

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.