Modify the ssh port and centosssh port of centos

Source: Internet
Author: User
Tags ssh port

Modify the ssh port and centosssh port of centos
Vi/etc/ssh/sshd_config
Find the section # Port 22, which indicates that Port 22 is used by default, and add a line as follows:
Port 34981

Save and exit

Then the service sshd restart

Note: Do not turn it off here.

In addition, open a new window and try to connect to sshd. If the connection is successful, delete port 22 and restart ssh. If not, use port 22.

In this way, no exception occurs when you reset the ssh port.


How does one change the SSH port in Linux?

Vi/etc/ssh/sshd_config, find Port 22, change Port 22 to the desired Port number, and restart the SSH service:/etc/init. d/sshd restart, and then test the ssh connection: ssh localhost-p your port number. The connection is successful. If you want to avoid using ssh connections because one port cannot be connected (for example, under attack), you can use multiple ssh connection ports, in the configuration file/etc/ssh/sshd_config, run vi/etc/ssh/sshd_config, find the Port, and add a line below: Port 23, in this way, a new connection port is added, the SSH service is restarted, and ssh localhost-p 23 is tested. The connection is successful. In addition, if the local test is normal, but you still cannot use the third-room tool to access the external SSH link, you need to disable the firewall and Restart SSHD. In this way, you can.

How can I change the port used for linux ssh?

Ssh? Do you want to change the server or client?

The command format is as follows:
Ssh-p port # host
If you use a port forward tool like proxy, run the following command:
Ssh-L local_port: remote_host: remote_port hostname
Here
Local_port can be any available local port, generally over 1024
Remote_host is

If the server is changed, the configuration file is modified. Generally, sshd is used. The configuration file is usually in/etc/ssh/sshd_config.
Search for # Port and replace # Port with the Port you want
If iptables has settings, do not forget to open the new 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.