SSH(安全外壳)(SSH (Secure Shell))协议通过验证远程用户并将输入从客户端传输到主机来工作。然后它将输出重新传输回客户端——通信是加密的,因此安全性比Telnet高得多。在这篇文章中,我们将说明如何在Windows 11/10OpenSSH客户端和服务器。
安装(Install)和配置OpenSSH客户端和服务器
首先,验证OpenSSH客户端安装。
- 按Windows键 + I 组合启动设置应用程序。(Settings)
- 在“设置”应用中,选择“应用(Apps)”子类别。
- 在应用程序和功能(Apps & features)窗口的右侧,单击可选功能(Optional features)链接。
- 在下一个打开的窗口中,向下滚动以找到OpenSSH Client。如果客户端已经安装,则不需要用户交互 - 否则,只需单击安装按钮。
完成后,接下来要执行的操作是在 Windows 10 上添加/安装OpenSSH服务器(OpenSSH)
仍然在Optional features窗口中 - 在顶部,单击Add a feature。
现在向下滚动并选择OpenSSH Server。单击“安装(Install)”按钮并在安装该功能时等待几秒钟。
操作完成后,重新启动计算机以确认更改。
客户端和SSH服务器现已安装。
现在,您需要将SSH 服务器(SSH server)配置为在每次启动 Windows 10 时启动。方法如下:
按Windows键 + R。在“运行”(Run)对话框中键入services.msc,按 Enter。
然后向下滚动并一个接一个地双击——OpenSSH SSH Server和OpenSSH Authentication Agent——并将启动类型(Startup type)设置为Automatic。
单击应用(Apply)>确定(OK)。
旁注(Side note):您可能看不到列出的OpenSSH SSH 服务器。(OpenSSH SSH Server)这意味着之前添加功能的操作失败。在这种情况下,您可以通过命令行安装该功能。就是这样:
打开提升的命令提示符。复制(Copy)并粘贴下面的命令并按Enter 键(Enter)以找出确切的功能/功能名称以及它是否存在于您的系统中,因为它是隐藏的。
dism /online /get-capabilities | findstr /i "OpenSSH.Server"
成功执行后,复制并粘贴以下命令,然后按 Enter(Enter)安装该功能:
dism /online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0
您无需重新启动 PC - 只需单击服务(Services)窗口上的操作(Action)菜单,然后单击刷新(Refresh)。将列出OpenSSH SSH 服务器功能。(OpenSSH SSH Server)
现在,有必要验证SSH服务是否处于活动状态。就是这样:
右键单击开始(Start)并选择Windows PowerShell ( Admin )。
在PowerShell窗口中,复制并粘贴下面的命令,然后按 Enter-
Get-Service -Name *ssh*
您将看到以下输出:
接下来,您必须配置Windows 防火墙(Windows Firewall)才能通过SSH访问您的计算机。为此,仍然在PowerShell窗口中,复制并粘贴下面的命令,然后按 Enter(Enter)。
.\netsh advfirewall firewall add rule name="SSHD Port" dir=in action=allow protocol=TCP localport=22
您现在可以测试SSH服务器是否正在侦听端口 22。为此,仍然可以在PowerShell窗口中复制并粘贴以下命令并按Enter 键(Enter)。
.\netstat -bano | .\more.com
您将看到以下输出:
提示:(Tip:)如果您没有看到列出的端口 22(Port 22),请重新启动您的 PC 并在启动时重新执行该命令。
展望未来,您现在可以远程连接到SSH服务器。要成功建立连接,需要以下参数:
- 用户名
- 用户密码
- 服务器的IP地址
- SSH服务器正在侦听的端口。在本例中,端口(Port)为 22。
要建立与OpenSSH服务器的连接 - 启动PowerShell,根据您自己的参数,键入下面的命令并按Enter。
ssh -p 22 [email protected]
在这里记得使用您的个人详细信息。
然后输入密码并再次按 Enter 键(Enter),以访问远程计算机——您将可以通过PowerShell访问SSH服务器。这样,您的数据就不会受到可能的威胁者的攻击。
这就是在 Windows 10 中使用 OpenSSH 配置安全连接的过程。(That’s it on configuring a secure connection using OpenSSH in Windows 10.)
Install and configure OpenSSH client and server on Windows 11/10
The SSH (Secure Shell) protocol works by authenticating a remote user and transferring inputs from the client to the host. It then re-transmits the output back to the client – the communication is delivered encrypted so the security is much higher than Telnet. In this post, we will illustrate how to install and configure both OpenSSH client and server on Windows 11/10.
Install & configure OpenSSH client & server
To begin, first, verify the OpenSSH client installation.
- Launch the Settings app by pressing the Windows key + I combo.
- In the Settings app, select the Apps sub-category.
- On the right side of the Apps & features window, click on the Optional features link.
- In the next window that opens, scroll down to locate the OpenSSH Client. If the client is already installed, no user interaction is required – otherwise, just click on the install button.
Having done that, the next action to perform is to add/install the OpenSSH server on Windows 10
Still in the Optional features window – at the top, click on Add a feature.
Now scroll down and select OpenSSH Server. Click on the Install button and wait a few seconds while the feature is installed.
Once the action is completed, restart the computer to confirm the changes.
The client and the SSH server are now installed.
Now you’ll need to configure the SSH server to start every time you boot Windows 10. Here’s how:
Press Windows key + R. In the Run dialog type services.msc, hit Enter.
Then scroll down and double-click one after the other – OpenSSH SSH Server and OpenSSH Authentication Agent – and set the Startup type to Automatic.
Click Apply > OK.
Side note: You may not see the OpenSSH SSH Server listed. This means that the previous action to add the feature failed. In this case, you can install the feature via the command line. Here’s how:
Open an elevated command prompt. Copy and paste the command below and hit Enter to find out the exact capability/feature name and if it’s present in your system because it’s hidden.
dism /online /get-capabilities | findstr /i "OpenSSH.Server"
Once that executes successfully, copy and paste the command below and hit Enter to install the feature:
dism /online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0
You do not need to restart your PC – just click on the Action menu on the Services window and click Refresh. The OpenSSH SSH Server feature will be listed.
Now, it is necessary to verify if the SSH services are active. Here’s how:
Right-click Start and select Windows PowerShell (Admin).
In the PowerShell window, copy and paste the command below and hit Enter-
Get-Service -Name *ssh*
You’ll be presented with the following output:
Next, you’ll have to configure the Windows Firewall in order to have access to your computer through SSH. To do so, still, in the PowerShell window, copy and paste the command below and hit Enter.
.\netsh advfirewall firewall add rule name="SSHD Port" dir=in action=allow protocol=TCP localport=22
You can now test whether the SSH server is listening on port 22. To do so, still, in the PowerShell window, copy and paste the command below and hit Enter.
.\netstat -bano | .\more.com
You’ll be presented with the following output:
Tip: If you don’t see the Port 22 listed, restart your PC and on boot, re-execute the command.
Going forward, you can now be able to connect remotely to an SSH server. To successfully establish a connection, the following parameters are required:
- User name
- User password
- Server IP Address
- The port where the SSH server is listening. In this case, the Port is 22.
To establish a connection to the OpenSSH server – launch PowerShell, depending on your own parameters, type the command below and hit Enter.
ssh -p 22 [email protected]
Here remember to use your personal details.
Then type the password and hit Enter again, to access the remote computer – and you will have access via PowerShell to the SSH server. In this way, your data remains safe from possible threat actors.
That’s it on configuring a secure connection using OpenSSH in Windows 10.