---
description: Install and Configure Open SSH Service on Windows Server
---

# Open SSH

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FTAaJFkpE66k6Tv90uzYN%2Fimage.png?alt=media&#x26;token=4429ca25-ddd2-40ae-8e19-caf493ff2427" alt=""><figcaption></figcaption></figure>

In this scenario, we will learn the steps on how to install and configure the Open SSH Server on Windows Server .&#x20;

### Understand the Test Lab Setup:

For this guide, we will use the test lab created in VMWare Workstation.

* **WinServer:** Domain Controller with DNS. (192.168.10.1/24)
* **Client:** Windows 10 client machine.&#x20;

### Installing OpenSSH with PowerShell:

1\. Logon to Windows Server with an administrator account.

2\. To install OpenSSH on Windows Server using PowerShell, first launch PowerShell as an Administrator.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FPPMrPyryy5uvmHwJPW6C%2Fimage.png?alt=media&#x26;token=87c6525f-0b22-4a6a-87bc-c3f35ae943e7" alt=""><figcaption></figcaption></figure>

3\. First, let’s verify that the OpenSSH package is available or not on the server before directly installing it.

```
Get-WindowsCapability -Online |? Name -like ‘OpenSSH*’
```

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FasleCyXxOzamA4qmjxLC%2Fimage.png?alt=media&#x26;token=0bad2371-1f0a-4ac0-9899-2a01b18afdf8" alt=""><figcaption></figcaption></figure>

4\. To install OpenSSH package run below cmdlet in Windows PowerShell.

```
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
```

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FLiJDT7jRkNnXhGN3YZ4a%2Fimage.png?alt=media&#x26;token=62516695-d4a8-49dd-8674-67b270826c32" alt=""><figcaption></figcaption></figure>

Verify the OpenSSH Server package is successfully installed on Windows Server.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F6li6iV6nWV1YpNchT3HT%2Fimage.png?alt=media&#x26;token=9227fd15-30dc-451c-9ae2-e5e47d75f0da" alt=""><figcaption></figcaption></figure>

### Configure SSH Server on Windows Server

Once the installation succeeds, the next step is the initial configuration of the SSH server. SSH services need to be configured for automatic start and started up.&#x20;

5\. First, check the status of sshd and ssh-agent service. To check that, we need to run below cmdlet at Windows PowerShell (admin).

```
Get-Service sshd
Get-Service ssh-agent
```



<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FURh5aKstWzlvBoAWjeDG%2Fimage.png?alt=media&#x26;token=c847267c-4d89-4261-8ff0-74906cc8ab0b" alt=""><figcaption></figcaption></figure>

6\. We can see that both services are in a Stopped status. Before starting the OpenSSH services, we need to change the startup mode. We need to run below cmdlet at Windows PowerShell (admin).

```
Set-Service -Name sshd -StartupType Automatic
Set-Service -Name ssh-agent -StartupType Automatic
```



<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FVTZzIGvTi3Hdwprixlry%2Fimage.png?alt=media&#x26;token=1743b1f2-49ae-4291-ac23-f82b8260c083" alt=""><figcaption></figcaption></figure>

7\. Now, let’s start both services. We need to run below cmdlet at Windows PowerShell (admin).

```
Start-Service sshd
Start-Service ssh-agent
```



<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F71gRevNpGBTu7jdNqgr9%2Fimage.png?alt=media&#x26;token=540a70a6-168d-421e-9c54-bfdefdd1fd41" alt=""><figcaption></figcaption></figure>

8\. Let’s again check the status of SSH services.

```
Get-Service sshd
Get-Service ssh-agent
```



<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FkchdBrIQyi1DqsxlkeBS%2Fimage.png?alt=media&#x26;token=85ce4480-b07f-4ec9-a85b-8a97a6ba9cca" alt=""><figcaption></figcaption></figure>

Now, we can verify SSH services are up and running.

### Test the SSH connection to the SSH server:

Starting from Windows 10, Windows 10 also comes with its SSH client, which is already installed in Windows 10 system.

9\. On a Windows 10 machine, open a command prompt (or Windows PowerShell) and type: below command to connect to the ssh server.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FVEvLr3S1j24ygoFD4IWB%2Fimage.png?alt=media&#x26;token=0b50a1f5-824b-4fe9-aeb6-627353934f2f" alt=""><figcaption></figcaption></figure>

```
ssh harchit.local\administrator@192.168.10.1
```

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FugsBgyYClmT704DsUZPj%2Fimage.png?alt=media&#x26;token=cf494417-b91a-4589-8b4a-a2de8891497e" alt=""><figcaption></figcaption></figure>

10\. **Type yes** at the warning message and **press Enter key.**

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F0SwqCgF7BsDEvFs7YEbS%2Fimage.png?alt=media&#x26;token=82ffde71-f5e3-4dd4-b280-c72dbce5fcae" alt=""><figcaption></figcaption></figure>

11\. **Type administrator accounts password** and **press enter key.**

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FKY03u8ryp37uuUVlhNvD%2Fimage.png?alt=media&#x26;token=4c1e78dc-489d-4842-ad27-4314c71f1a1e" alt=""><figcaption></figcaption></figure>

Now we can run any command we want as if we were sitting in front of our server.

Lets run command **“netstat -n”** to check the established connection from Windows 10 client machine.

Here, we can see SSH session from Windows 10 client machine to our SSH Server on TCP port number 22.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F48pPoDPNjd2hqRX52MIV%2Fimage.png?alt=media&#x26;token=8c7bf8a5-db5b-4f86-a28d-b75fa97d980b" alt=""><figcaption></figcaption></figure>



