Install OpenSSH online and offline under Windows

?

Windows 10 comes with a new feature that allows you to install the Openssh server and client, which allows us to access other machines such as Linux through the SSH client on the Windows machine, or access the Windows machine through the SSH client on other machines. . In this way, remote Windows command line can be as convenient as remote Linux.

?

At the same time, OpenSSH also provides SFTP support, which also allows us to exchange files remotely. Next, this article introduces two methods of installing OpenSSH online and offline after Wnidows 10, and also introduces some operations and usage modes.

Online installation

If you have a Windows 10 or above machine that is already connected to the Internet, you can install OpenSSH through the following steps. Take Windows 11 as an example.

  1. First, open the Settings interface and select Application and Optional Features in the settings.

  1. Select Add Optional Features in Optional Features, and click View Features on the right

  1. If the OpenSSH server or client has not been installed on this machine, you will be able to see the OpenSSH client and OpenSSH server functions in the pop-up Add Optional Function dialog box.

Next select these two OpenSSH functional components and click Next.

  1. Next, the installation dialog box will pop up. At this time, click Install to enter the installation interface.

In the installation interface, the OpenSSH server and client will be downloaded and then installed.

After the installation is completed, you can enter the ssh command in PowerShell to access the remote machine. The remote machine can also access the local machine through the ssh command.

Offline installation

Generally, you can use the above method to successfully install the openssh server directly in the Optional Features in Settings, and then directly use the command line to start related services. However, sometimes the above operation does not work well and the installation often fails. Then, we need to install it offline.

  1. The offline package comes from Microsoft’s open source SSH project on Github, so we can directly download the OpenSSH offline installation package. The warehouse address is Releases · PowerShell/Win32-OpenSSH · GitHub.

  1. Find the latest version of the ZIP installation package in the release of the warehouse address. As shown below, download the OpenSSH-Win64.zip file according to your own system (choose the respective versions for 32-bit and ARM machines), or use OpenSSH-Win64-v9.4.0. 0.msiinstallation package.

  1. If it is a ZIP, decompress the files in the compressed package and copy them to the C:\Program Files\OpenSSH directory (create a new one if it does not exist). Then open PowerShell as an administrator and execute in the current directory:

powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1

If it is MSI, directly double-click the msi file to install.

  1. After installing Ancheng, open Powershell and start the SSH service:

net start sshd

Run PowerShell as administrator

Run PowerShell as administrator

Start SSH server

Start SSH server

  1. If you need to start automatically every time you turn on the computer, enter the following command in PowerShell

Set-Service sshd -StartupType Automatic

  1. Finally, if you have any questions, you can check the existing issues on Github to see if there are any matches. If there are no matches, you can create a new issue to ask questions.

Wind32-OpenSSH project issues

Issues of Wind32-OpenSSH project

Access files under Windows under Linux

After installing the Windows software through the above steps, we can quickly access files in Windows through nautilus in the GNOME desktop environment of Linux, using the sftp protocol behind it.

  1. First, open the nautlius browser in the gnome desktop, click Other Locations on the left, a popup will pop up to connect to the server, and enter the username and IP address required to log in to the Window machine in the address bar. Then click Connect.

We may be asked to enter a username and password when connecting for the first time. At this time, follow the normal login of the Windows machine and enter the user name and password. After the input is completed, you can see the disk in the remote Windows machine.

?

After connecting, we can also click the upper triangle arrow on the right side of the network location to disconnect like a mobile hard disk or USB flash drive.

?

In this interface, we can view files in the remote machine just like browsing local files. We can also right-click on the current path to open the local terminal or remote terminal (the local terminal is the gnome-terminal that comes with Linux, and the remote terminal is on the remote machine. powershell), which can complete various file operations.