Change the default ssh port in CentOS

Source: Internet
Author: User
Tags ssh port

Change the default ssh port in CentOS

If you want to change the port and break through the port whitelist, but it does not work, record the process.

1. modify the configuration file

/Etc/ssh/sshd_config

#Port 22

Uncomment this line and add a new port

Port 22Port 1234
2. Restart sshd

There are several methods to choose from. If putty or another tool is used, if port 22 is always enabled, the ssh connection does not seem to be disconnected.

Method 1

/etc/init.d/sshd restart

Method 2

service sshd restart

Method 3 (Use this command on many vps instances)

systemctl restart sshd.service

Use systemctl to view service status

systemctl status sshd.service

Method 4: Start a new sshd process directly (as if not, it will be connected to closed)

/usr/sbin/sshd -p 2233
3. Check whether the netstat port is enabled.
net -an| grep [port]

If enabled, you can use the new port to log on.

ssh -p 1234 username@hostip

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.