OpenSSH is a built-in component of Windows Server 2016 and Windows 10.
Use following commands to install OpenSSH server:
PS C:\Users\anton> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Use administrator credentials for connection.
PS C:\Users\anton> ssh administrator@server2019.saritasa.local
The authenticity of host 'server2019.saritasa.local (192.168.11.137)' can't be established.
ECDSA key fingerprint is SHA256:LjsYblKkKkaidWJBpSuL+PivLoMU0CBD9Nv0lIqznwU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'server2019.saritasa.local' (ECDSA) to the list of known hosts.
[email protected]'s password:
Microsoft Windows [Version 10.0.17666.1000]
(c) 2018 Microsoft Corporation. All rights reserved.
administrator@SERVER2019 C:\Users\Administrator>hostname
server2019
Read the article for advanced configuration.
Make sure a line presents in C:\ProgramData\ssh\sshd_config
.
PubkeyAuthentication yes
You may want to disable a password authentication also.
PasswordAuthentication no
Use ssh-copy-id command to publish an SSH key to a server from a Linux machine. The tool is not a part of OpenSSH for Windows.
Alternative way - add an OpenSSH public key from id_rsa to %USERPROFILE%\.ssh\authorized_keys
on remote server using SFTP, PowerShell Remoting or RDP.
Add-Content -Encoding utf8 ~\.ssh\authorized_keys 'ssh-rsa ...'
Make sure you have correct permissions for the .ssh
folder. Read the article for details: Security protection of various files in Win32 OpenSSH
PowerShell Core supports WSMan and SSH for remoting.
Configure SSH subsystem on server according to the article.
Use Chocolatey to install PowerShell Core to client:
cinst powershell-core -y
Alternatively follow the article: Installing PowerShell Core on Windows
Run PowerShell 6.0.2 from Start menu or by full path: C:\Program Files\PowerShell\6.0.2\pwsh.exe
Connect to server:
PS C:\Program Files\PowerShell\6.0.2> Enter-PSSession -HostName server2019.saritasa.local -UserName administrator
You may install PowerShell Core to Linux and connect to Windows servers over SSH. Read the article for details.
anton@ANTON-PC:~$ pwsh
PowerShell v6.1.0-preview.2
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /home/anton> Enter-PSSession -HostName server2019.saritasa.local -UserName anton
The authenticity of host 'server2019.saritasa.local (192.168.11.137)' can't be established.
ECDSA key fingerprint is SHA256:LjsYblKkKkaidWJBpSuL+PivLoMU0CBD9Nv0lIqznwU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'server2019.saritasa.local' (ECDSA) to the list of known hosts.
[email protected]'s password:
[server2019.saritasa.local]: PS C:\Users\anton\Documents>
Current version of OpenSSH for Windows (7.7.1) has serious issues with interactivity. Applications like Far Manager, Midnight Commander, Nano do not work correctly.
See the issue.