Modify the default port number ssh server

1, view the current ssh server port number

Before you modify the port number ssh server, first check the port number ssh server is listening, use the netstat command:

$ sudo netstat -tunlp | grep "ssh"

Run results are shown, the default port number is generally 22:

 

2, how to modify the default ssh server port

In the above has been described how to view the ssh server port number, then describes how to modify the default ssh server port number:

Ssh server can modify the configuration files, in Ubuntu system, ssh service profile path of / etc / ssh / sshd_config, using the following command is modified:

$ sudo vim /etc/ssh/sshd_config

As modified, the listening port number 10022 is newly added, it is noted that the addition of the best listening port number range of 10000 to 65535, to prevent the selected port number is occupied by the system or other software.

After the ssh server configuration file is modified, you need to restart the ssh services that allow the entry into force of the new listening port, use the following command:

$ sudo service ssh restart

After the reboot is complete, use the netstat command to view the new listening port number:

$ sudo netstat -tunlp | grep "ssh"

Can be seen from the above operating results, 10022 listening port has been added successful.

After modifications are complete, we need to test the connection can be tested in the original terminal, use the following command ssh connection:

$ ssh hly@localhost -p 10022

The connection process, the user needs to enter a password, the results as shown below, then the test passes:

When the test is passed, the default can ssh server port 22 blocked, and also modify the configuration file ssh server, ssh then restart the service.

Guess you like

Origin www.cnblogs.com/Cqlismy/p/11539702.html