OpenSSH Server and Client
Install feature
- Open Settings, select System, then select Optional Features.
- Select Add a feature if not installed:
- Find OpenSSH Client, then select Install
- Find OpenSSH Server, then select Install
Add Public key authentication
Setting up OpenSSH for Windows using public key authentication
-
Update permission in
$env:USERPROFILE\.ssh\authorized_keysfile.- Properties > Security > Advanced >
Disable inheritance> Save. - Create Full Access permission for
SYSTEMandAdministratorUser.
- Properties > Security > Advanced >
-
Update config in
C:\ProgramData\ssh\sshd_configfile.-
Uncomment
PubkeyAuthentication yes -
Comment following segment
Match Group administrators AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
-
-
Restart OpenSSH Server service.
- Start Menu > Run >
services.msc - Restart OpenSSH Server.
- Change Startup type to Automatic.
- Start Menu > Run >
Create Connection
Username
$env:USERNAME
Server name
ipconfig | select-string ('(\s)+IPv4.+\s(?<IP>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(\s)*') -AllMatches | %{ $_.Matches } | % { $_.Groups["IP"]} | %{ $_.Value }
Connect VM
ssh user@host
SCP from windows
scp -T 'user@host:"C:\path to file\file.txt"' ./