Configure SSH Server and SSH Client on Windows Server 2019

 217 total views


2021-03-22 21:34:42

Configure SSH Server on Windows Server 2019

1. Run Powershell with admin rights and configure SSH server as follows:

PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# get available name of OpenSSH
PS C:UsersAdministrator> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' 

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

# Install OpenSSH Server
PS C:UsersAdministrator> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 

Path          :
Online        : True
RestartNeeded : False

# start sshd service
PS C:UsersAdministrator> Start-Service -Name "sshd" 

# set [Automatic] for Startup
PS C:UsersAdministrator> Set-Service -Name "sshd" -StartupType Automatic 

# verify
PS C:UsersAdministrator> Get-Service -Name "sshd" | Select-Object * 

Name                : sshd
RequiredServices    : {}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : True
DisplayName         : OpenSSH SSH Server
DependentServices   : {}
MachineName         : .
ServiceName         : sshd
ServicesDependedOn  : {}
ServiceHandle       : SafeServiceHandle
Status              : Running
ServiceType         : Win32OwnProcess
StartType           : Automatic
Site                :
Container           :


# if Windows Firewall is running, allow 22/TCP
PS C:UsersAdministrator> New-NetFirewallRule -Name "SSH" `
-DisplayName "SSH" `
-Description "Allow SSH" `
-Profile Any `
-Direction Inbound `
-Action Allow `
-Protocol TCP `
-Program Any `
-LocalAddress Any `
-RemoteAddress Any `
-LocalPort 22 `
-RemotePort Any 

Name                  : SSH
DisplayName           : SSH
Description           : Allow SSH
DisplayGroup          :
Group                 :
Enabled               : True
Profile               : Any
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

2. Open Start> Settings.

Settings” width=”650″ height=”488″ class=”lazy” data-src=”https://st.CHK.com/photos/image/2021/03/22/cau-hinh-ssh-server-ssh-client-1.jpg”/>
Open Start> Settings

3. Click Apps.

Click on Apps
Click on Apps

4. Click Manage optional features.

Click Manage optional features
Click Manage optional features

5. Click Add a feature.

Click Add a feature
Click Add a feature

6. Select OpenSSH Server and click the button Install.

Select OpenSSH Server
Select OpenSSH Server

7. After the installation is completed, the OpenSSH Server will be added to the services. Launch it and change Startup Fort Automatic.

OpenSSH Server will be added to the services
OpenSSH Server will be added to the services

8. If Windows Firewall is running, please allow SSH service port (22 / TCP).

Allow SSH service port (22 / TCP)
Allow SSH service port (22 / TCP)

Configure SSH Client on Windows Server 2019

1. On Windows Server 2019, OpenSSH Client is installed by default. But if it is not already installed, please install from Start> Settings> Apps>> Manage optional features> Add a feature> OpenSSH Client.

Install OpenSSH Client
Install OpenSSH Client

2. You can use the ssh client command as follows on PowerShell or Command Prompt:

PS > ssh (username)@(Hostname hoặc địa chỉ IP của SSH server)
Use the ssh client command
Use the ssh client command

3. You can also log into the Linux Host on which the SSH server is running.

Log in to the Linux Host on which the SSH server is running
Log in to the Linux Host on which the SSH server is running

4. You can also use commands scp and orders sftp to transfer SSH files.

.

#Configure #SSH #Server #SSH #Client #Windows #Server

Related Posts

Leave a Reply

Your email address will not be published.

Close Bitnami banner
Bitnami