Bootstrap

ssh修改端口号_如何查找和更改SSH端口号?

ssh修改端口号

ssh修改端口号

ssh  is the default protocol used to manage remote systems which are mainly Linux and Network Devices. As it is working over a network connection and uses TCP it has a default port number which is 22. In this tutorial, we will look at how to change the default port number from the client and server point of view.

ssh是用于管理主要是Linux和网络设备的远程系统的默认协议。 由于它通过网络连接工作并使用TCP,因此其默认端口号为22。在本教程中,我们将从客户端和服务器的角度研究如何更改默认端口号。

列出SSH服务器端口配置 (List SSH Server Port Configuration)

Linux ssh server configuration is stored in /etc/ssh folder with a name sshd_config .  This configuration file provides a lot of configuration parameters. We can print the current port configuration with the following command by grepping Port text.

Linux ssh服务器配置存储在名称为sshd_config /etc/ssh文件夹中。 该配置文件提供了许多配置参数。 我们可以通过以下命令打印当前端口的配置,即grepping Port文本。

$ cat /etc/ssh/sshd_config  | grep Port

更改SSH服务器端口配置 (Change SSH Server Port Configuration)

In order to change port configuration we just need to remove the # from begging of the configuration line with is listed in the previous step. So

为了更改端口配置,我们只需要从上一步中列出的配置行开头删除# 。 所以

#Port 22

will change to the below where number is the port number we want.

将更改为以下内容,其中number是我们想要的端口号。

Port 2222

and We need to restart the ssh service in order to affect changes.

并且我们需要重新启动ssh服务以影响更改。

$ sudo systemctl restart ssh

更改SSH客户端端口配置 (Change SSH Client Port Configuration)

Now we have changes ssh port of the server but how can we specify different port than 22 in ssh client. We use a Linux ssh client which uses port 22 as default. We will use -p option in order to specify the port number we want to connect. In this example, we will connect to the port number 2222.

现在我们更改了服务器的ssh端口,但是如何在ssh客户端中指定不同于22端口。 我们使用Linux ssh客户端,该客户端默认使用端口22。 我们将使用-p选项来指定我们要连接的端口号。 在此示例中,我们将连接到端口号2222

$ ssh -p 2222 192.168.1.1
LEARN MORE  Linux SCP Command Usage With Examples
通过示例了解更多Linux SCP命令用法

翻译自: https://www.poftut.com/how-to-find-and-change-ssh-port-number/

ssh修改端口号

;