Bobcares

How to install and configure OpenSSH on Windows

by | Feb 4, 2021

If you have a group of servers with Linux and Windows operating systems, then it is a good consideration to install and configure OpenSSH on Windows.

Because it would be easy to manage the servers using OpenSSH. Also, it encrypts traffic on both ends, eliminating security risks from hackers or eavesdroppers.

Moreover, we can use it for remote operations like file transfers and offers key-based password-less authentication.

Here at Bobcares, we have seen several such Windows-related errors as part of our Server Management Services for web hosts and online service providers.

Today we’ll see how to install and configure OpenSSH on Windows.

 

How to Install and Configure OpenSSH on Windows

Now let’s take a look at how our Support Engineers install OpenSSH on Windows Server.

 

1. Using Powershell as an Administrator User

  • First, we open Powershell as an Administrator User.
  • We begin by clicking on the “Start” button and click on “All Apps”.
  • Next, we expand the Powershell folder, and right-click on “Powershell” and select “Run as administrator.
  • Depending on machine settings, we may receive a “UAC” or User Access Control prompt asking us to allow it. We go ahead and approve the access.

 

2. Install OpenSSH client

Next, we install the OpenSSH client by executing the necessary commands. The client is the software that we use to connect to the OpenSSH server. Here, we will connect from our local laptop or workstation, so we begin by opening Powershell. In the Powershell prompt, we run the below command.

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0</code.

We can see a progress bar indicating the progress of the installation. Once the installation completes, we will receive the following output.

Path :
Online : True
RestartNeeded : False

 

Step 3: Install the OpenSSH server

Now, we shall install the OpenSSH server. Here the server is the computer that runs in the sshd service. In the Powershell prompt, we execute the below command.

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0;

Again, here can see a progress bar indicating the progress of the installation. Once the installation completes, we can see the below output.

Path :
Online : True
RestartNeeded : False

 

Uninstalling OpenSSH on Windows

In case, if we wish to remove the client or the server, then we run the below respective commands to remove them.

# Uninstall the OpenSSH Client
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Uninstall the OpenSSH Server
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

 

How to configure OpenSSH on Windows

After the installation of OpenSSH software, we can now configure it. Now, we shall set the sshd service to start on boot. This action will ensure to automatically restart the service if a reboot or power failure occurs. Here is the command that we execute in the Powershell prompt. This will start the service and set it to start automatically.

Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

In order to allow a secure connection to our server, we need to add a firewall rule. This rule will allow inbound ssh traffic on port 22. To verify, we type this command at the Powershell prompt.

# Confirm the Firewall rule is present. It should be created automatically by setup.
Get-NetFirewallRule -Name *ssh*

Now, we can see an enabled firewall rule named “OpenSSH-Server-In-TCP.” In the event we do not see a firewall rule, we will need to create one. For that, we run the following command.

New-NetFirewallRule -Name sshd -DisplayName' OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

 

Using OpenSSH

After having the OpenSSH server and client installed, we can now test the setup. now, we can check the connectivity from any Linux, Mac, or Windows device using an installed SSH Client. In Windows, we execute the following command in PowerShell.

ssh Administrator@ip_address

NOTE: Replace the IP above with the IP address of your server

If connecting for the first time, then we will be asked to confirm the connection. We type “yes” and hit Enter.

The authenticity of host' ip_address (ip_address)' can't be established.
ECDSA key fingerprint is SHA256:aMmHNXmcgX2DHuFL0V9lSpY8AX45iHQeBxVD1oZgr4w.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added 'ip_address' (ECDSA) to the list of known hosts.

Next, we enter the user password after it prompts for it.

After successful authentication of the user, we will be greeted with a command shell prompt.

The remote SSH session or “secure shell” is now live, and we can begin sending remote commands.

 

Transferring Files with OpenSSH after we install and configure it

Now let’s see how we can transfer files using OpenSSH. Here we are making use of the SCP file transfer utility provided by OpenSSH to transfer a file named “FileOnMyClient.txt” to the Administrator’s folder on our OpenSSH server.

From any Linux, Mac, or Windows device with the SSH Client installed, we can navigate to the folder our file is in by using the “cd” command.

cd Documents

NOTE: This assumes the file is in the Documents folder on the client.

In Powershell, we type the below command to transfer the file to the Administrators folder on the server:

scp bobtest.txt Administrator@ip_address:/Users/Administrator/

Then we enter the password when prompted for and hit enter. We will see output similar to the following information indicating the transfer percentage, transfer speed and timeframe of the transfer.

Administrator@ip_address’s password:
bobtest.txt 100% 0 0.1KB/s 00:05

Next, in order to verify that the file is transferred successfully, we must go back to our server and type in the dir command again which lists all the files in that particular folder. As we can see, we have successfully transferred our text file.

administrator@server C:\Users\Administrator>dir
Volume in drive C has no label.
Volume Serial Number is AEF3-9E8C
Directory of C:\Users\Administrator
01/25/2021 07:52 AM
01/25/2021 07:52 AM..
02/01/2021 12:45 PM3D Objects
02/01/2021 12:45 PMContacts
02/01/2021 12:45 PMDesktop
02/01/2021 12:45 PMDocuments
02/01/2021 12:45 PMDownloads
02/01/2021 12:45 PMFavorites
02/01/2021 12:45 PMLinks
02/01/2021 12:45 PMMusic
02/01/2021 12:45 PMPictures
02/01/2021 12:45 PMSaved Games
02/01/2021 12:45 PMSearches
02/01/2022 12:45 PMVideos
1 File(s) 15 bytes
14 Dir(s) 129,640,345,600 bytes free

We can also check the contents of our text file by using the built-in Windows command “type” command, followed by the name of the file.

administrator@server C:\Users\Administrator>type bobtest.txt

 

Some common errors and fix relating to OpenSSH

Now let’s take a look at some of the common errors our customers came across and also let’s see how our Support Engineers fix them.

1. Add-WindowsCapability failed. Error code = 0x800f0950

If the build of the system is older than 17763.194, we will see this error. The installation of the OpenSSH server fails on earlier builds of Windows Server 2019.

Solution:

From gpedit.msc (Group Policy), we select Computer Configuration >> Administrative Templates >> Windows Components >> Windows Update >> Specify intranet Microsoft update service location >> Finally, we set it to Disabled.

 

2. Error with “Add-WindowsCapability”. Error code: 0x8024002e

This error occurs if the server is updated via WSUS. Microsoft delivers features on-demand bypassing WSUS, so we do not get them via the internal update server.

In the event log, you will then find an entry with ID 1001 stating that the OpenSSH-Server-Package is not available.

Solution: Allow Windows to load optional features directly from Microsoft Update via group policy. This setting is “Specify settings for optional component installation and component repair,” and we can find it under Computer Configuration >> Policies >> Administrative Templates > System.

At the same time, ensure that neither the setting “Do not connect to Windows Update Internet locations” nor “Remove access to use all Windows Update features” is in effect.

[Still not able to install and configure OpenSSH on Windows? – We are here to help you]

 

Conclusion

Today, we saw how our Support Engineers install and configure OpenSSH on windows. Also, we saw some common errors relating to OpenSSH.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF