Linux Change SSH port number

Source: Internet
Author: User
Tags ssh port

The first type:

01 If you want to change the default SSH port (22), then you just modify:/etc/ssh/sshd_config in Port 22, here to change the 22 to their own port to set the line, but do not set and now have the same port, oh, in case of unknown consequences.

02 If you want to limit the SSH login IP, then you can do the following:

First: Modify the/etc/hosts.deny and add the Sshd:all

Then: Modify:/etc/hosts.allow, in which the following settings: sshd:192.168.0.241

This allows you to limit only 192.168.0.241 of IP access to the Linux machine via SSH. Of course, as a server, I do not install GNOME and KDE, and a lot of things are not installed, so as to increase the safety factor.

The second type:

First modify the configuration file

Vi/etc/ssh/sshd_config

Find the #port 221 segment, here is the identity by default using 22 port, modified as follows:

Port 22

Port 10000

And then save the exit

Execute/etc/init.d/sshd Restart

This way the SSH port will work with both 22 and 50000.

Now edit the firewall configuration: vi/etc/sysconfig/iptables

Enable Port 10000.

Execute/etc/init.d/iptables Restart

Now, use the SSH tool to connect to port 10000 to test for success. If the connection is successful, edit the Sshd_config settings again and delete the Port22 inside.

The reason is set to two ports, test success and then close a port, is in order to modify the Conf in the process, in case of falling off, network, misoperation and other unknown circumstances, but also through another port connection debugging to avoid the connection must send people to the computer room, resulting in more complex problems.

[If you do not configure a firewall, you can also turn off the firewall (not recommended)]

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.