opened image

How to get OpenSSH up on Windows 2012

For those looking for a way to implement OpenSSH in a Windows environment, this article provides a simple guide to installing and configuring OpenSSH on Windows Server 2012 R2.

 

1. Downloading the OpenSSH distribution

Go to the official OpenSSH release page and download the latest version of the distribution. At the time of this writing, the current version is v9.2.2.0p1-Beta   For this example, I downloaded OpenSSH-Win64.zip.

 

 

2. Unpack and install the OpenSSH distribution

Create a directory C:\Program Files\OpenSSH and unzip the contents of the downloaded archive into it.

 

 

Run Powershell as administrator and run the following commands:

 cd "\Program Files\OpenSSH" .\install-sshd.ps1 

 

 

If you encounter a security policy error, try performing the installation using this command:

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

 

3. Key generation

 .\ssh-keygen.exe -A 

If you try to generate keys with the .\ssh-keygen.exe -A command, an error may occur. To fix it, go to C:\ProgramData and create the "ssh" directory. After that, run the command again to generate the keys.

 

 

 

4. Configuring Access Rights

To properly configure file access, run the following command:

 PowerShell -ExecutionPolicy Bypass -File .\FixHostFilePermissions.ps1 

Respond to each request with "A".

 

 

5. Configuring the Firewall

OpenSSH runs on TCP port 22 by default. To allow access, add a rule to Windows Firewall using the following command:

 New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH

 

Alternatively, you can do this through the GUI using the "Windows Firewall with Advanced Security" tool.

 

6. Start the OpenSSH service

Go to the list of services by selecting services.msc and look for "OpenSSH SSH Server". Set this service to start automatically and run it.

 

7. Verification of work

To verify that port 22 is active, perform:

 netstat -a | findstr "22"

If the port is listening, it means that the installation was successful.

 

 

8. Checking OpenSSH

Now that the service is running, you can verify that it is working. Connect to the server using the following command:

 ssh <username>@<your_server_ip>

If the connection is successful, it means that OpenSSH is installed and configured correctly.

 

In conclusion, OpenSSH – is a powerful tool to securely access remote servers. With it, you can easily and securely manage servers without worrying about the security of the data being transmitted.

We also suggest you other useful articles: