CentOS Modify SSH Port

Source: Internet
Author: User
Tags ssh port

1. Edit firewall configuration:
Vi/etc/sysconfig/iptables
Firewall Add new port 2222
-A input-m State--state new-m tcp-p TCP--dport 2 222-j ACCEPT
======================================================================
# Firewall Configuration written by System-config-firewall
# Manual Customization of the This file was not recommended.
*filter
: INPUT accept [0:0]
: FORWARD accept [0:0]
: OUTPUT accept [0:0]
-A input-m state–state established,r Elated-j Accept
-a input-p icmp-j accept
-a input-i lo-j accept
-a input-m state–state new-m tcp-p tcp– Dport 22-j Accept
-a input-m state–state new-m tcp-p tcp–dport 2222-j Accept
-a input-j reject–reject-with icmp-host-prohibited
-A forward-j reject–reject-with icmp-host-prohibited
COMMIT
Restart the firewall for the configuration to take effect:
/ Etc/init.d/iptables Restart or
service iptables restart

2. Backup SSH port configuration file
Cp/etc/ssh/ssh_config/etc/ssh/ssh_configbak
Cp/etc/ssh/sshd_config/etc/ssh/sshd_configbak
Modify the SSH port to: 2222
Vi/etc/ssh/sshd_config
Add port 2222 below ports #port 22
Vi/etc/ssh/ssh_config
Add port 2222 below ports #port 22
Restart:
/etc/init.d/sshd restartOr
service sshd restart
After the 2222 port can be connected normally, return to repeat the above steps. The 22 port is disabled, and then SSH can only be connected with 2222 port!

CentOS Modify SSH Port

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.