Install the Microsoft version of OpenSSH on Windows 10

Install the Microsoft version of OpenSSH on Windows 10

The operating environment is set in Anniversary Update

 OpenSSH is an open source software for using Secure Shell protocol.The OpenBSD project is the center of development.This OpenSSH contains both SSH client / server, but is a command line program that runs in a console window instead of a GUI app.

 OpenSSH has existed more than before and can be used in Windows, but there was a problem on the Windows side and the use as an SSH client was limited.

 This is because the exclus sequence in the console window is not supported up to Windows 8, and even if it is connected to the Linux machine, the Linux application side cannot use it as a "dam terminal" that cannot be controlled.I couldn't use a screen editor, for example.

 However, when Windows Subsystem for Linux was introduced in Windows 10 Ver.1607 (RS1, Anniversary Update), escape sequences were available in the Windows console window.For this reason, it is now possible to use screen editor such as Windows 10 to Linux using OpenSSH.In addition, OpenSSH can be used as a server or as a client.Here, we will explain the installation of OpenSSH.

Actually download and install

 OpenSSH, which Microsoft has transplanted, can obtain execution binary from the following URL.

H tsu TPS: // Gettu B.Ko M / Po -R She L / U -U -Pon 32 -Open SH / Lea Asus S

 Distribution is a ZIP compression file, which contains the required executable files.There are 32-bit, 64-bit version, with symbols for debugging, and no symbols, but usually select either OpenSSH-Win32.zip or "OpenSSH-Win64.zip" without symbols.The former is a 32 -bit version and the latter is 64bit version.Select according to your own execution environment.

 If you create an appropriate folder and decompress the zip file in it, the installation itself will end.However, in OpenSSH, the necessary information is saved in the installation folder as a file, so it is better not to place it in a folder with a writing restriction.

 In addition, the files are placed in another location because the writing restrictions are applied to the PROGRAM Files and Program Files (X86) folders and the folder virtualization mechanism works for compatibility with past applications.It will be.In that case, you have to find the necessary files when the system is migrated.

 So, in this article, we will create a folder (C: \ OpenSSH) called "OpenSSH" in the root folder of the C drive and install it there.Of course, you can set the folder freely, but in that case, please rewrite the pass specified by the following commands according to your environment.

 The setting is required only when moving the server, but even a Windows machine is worth moving the server.If you set the router's firewall function correctly, you can access it from the Internet side, and even with a local network, there is no need to open a remote desktop or move to another machine if you work with a command line.。

 In the unlikely event that Windows cannot be operated with a mouse, SSH remote login may be able to operate, and the possibility that it can be operated again by terminating the problematic program with the tasklist and taskkill command from the command line.There is also.The same was possible on the Telnet server attached to Windows, but this Telnet had only a flat sentence password or NTLM authentication, so setting it to the external machine has security problems.。However, OpenSSH can reduce security problems.

 Of course, you can use the Server Broker version of SSH server that automatically moves when you turn on the developer mode, but there is no information, for example, I do not know how to register a client's public key on the server (whether it is possible in the first place (in the first place).Including).So, if you want to operate the SSH server, you should switch to OpenSSH.

マイクロソフト版のOpenSSHをWindows 10にインストールする

Make it before setting OpenSSH

 First, select "Developer mode" in "Settings" → "Update and Security" → "Developer".

Turn on the developer mode.It is not directly related to OpenSSH, but by turning on the developer mode, you can set the PowerShell execution policy from the GUI.

 As a result, the execution policy of PowerShell is possible using the GUI.Then, refer to the previous article to stop the Server Broker version of the SSH server (when the developer mode is on) so that the state is not started as "invalid".Note that if Future Update is applied, the status of the Server Broker version of the SSH server may be switched to "manual" and started.

 In the MS version of OpenSSH, PowerShell uses PowerShell.For this reason, it is necessary to change the execution policy of PowerShell so that a non -signed script file can be used to execute the local file.For "developers", there is an item called "PowerShell", where there is a check box "Do not sign ...".

Press the "PowerShell" button in "Settings" → "Update and Security" → "For Developers" to change the execution policy of PowerShell

 Press the "Apply" button under this so that PowerShell can execute the local file without signature.

 Next, check the settings.To do so, start PowerShell and execute "Get -ExecutionPolicy -List".It is OK if "Remotesigned" is displayed next to "Current User".

If you start PowerShell and execute the "get -executionPolicy -List" command, "Current User" is "Remotesigned" if the right side of "Current User" is OK.

 The same can be set manually.To do so, start the PowerShell from the menu or start menu opened with Win+X key with administrator privileges and execute the following command.

If you want to change the execution policy manually, use the "Set-ExecutionPolicy" command.The same check method of the result is the same

Set -executionPolicy -scope Currentuser Remotesigned

 This "Remotesigned" means that you need to sign a script file via a network, but you don't need to sign a local script file.

 Next, register the OpenSSH installed path to the PATH environment variable so that it is easy to use from the command line.By doing so, the command prompt window allows the OpenSSH command to be executed without setting a full pass.

 The dialog box of the environment variable is displayed in "Control Panel" → "System" → "System Details Settings" → "Environment variable button".There are two lists, but the top is the environment variable for the user, and the bottom is the environment variable setting of the entire system.

 Considering the possibility of using OpenSSH from multiple user accounts, select "PATH" in the "System Environment variable" below and press the "Edit" button.The search path of the executable file registered in the PATH environment variable is displayed in a list format. Press the "New" button and enter the OpenSSH installation path (C: \ Openssh).

 The OpenSSH path is now set, and the OpenSSH command can be called in the open command prompt window.Basically, SSH.EXE, an OpenSSH client, can be executed in this state.As a simple usage, use the IP address of the connection destination or the host name in the LAN as an argument.

SSH PC1

By doing so, you can connect to other machines that operate the SSH server.

If you set the path, you will be able to execute SSH.EXE, SSH client.

 For the time being, the client has started to work, so next time I will explain the server side settings.