-
Notifications
You must be signed in to change notification settings - Fork 803
Install Win32 OpenSSH
-
Note these considerations and project scope first.
-
Download the latest build of OpenSSH. To get links to latest downloads this wiki page.
-
Extract contents of the latest build to
C:\Program Files\OpenSSH -
Start Windows Powershell as Administrator
-
Navigate to the OpenSSH directory
cd 'C:\Program Files\OpenSSH'
-
On Windows 10, if you've enabled Developer Mode, you probably have another implementation of SSH installed on your machine. To figure out if this is the case, look for TCP port bindings on port 22 and these services: “SSH Server Broker” and “SSH Server Proxy”
netstat -anop TCP- If you do see 22 occupied, #610 has workarounds to deal with port conflict.
-
Install
sshdandssh-agentservices.powershell -ExecutionPolicy Bypass -File install-sshd.ps1
-
Generate SSH host keys
.\ssh-keygen.exe -A-
Powershell.exe -ExecutionPolicy Bypass -Command ". .\FixHostFilePermissions.ps1 -Confirm:$false"(Note the first "." is a call operator.)
-
Secure SSH host keys (optional)
Start-Service ssh-agent- Download psexec from here
- Launch cmd.exe as SYSTEM
psexec.exe -i -s cmd.exe
- register host keys in above cmd.exe
ssh-add ssh_host_dsa_keyssh-add ssh_host_rsa_keyssh-add ssh_host_ecdsa_keyssh-add ssh_host_ed25519_key
- Host private keys are now securely stored by ssh-agent, private key files can be deleted at this point.
sdeletemay be used to securely erase them.
-
Open the firewall on TCP port 22 to allow inbound SSH connections
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Service sshd -Enabled True -Direction Inbound -Protocol TCP -Action Allow
Note:
New-NetFirewallRuleis for servers only. If you're on a client desktop machine (like Windows 10) try:netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP service=sshd -
Setup
sshdandssh-agentto auto-start (optional)Set-Service sshd -StartupType AutomaticSet-Service ssh-agent -StartupType Automatic
-
Start the
sshdandssh-agentnet start sshd
-
Configuring the default ssh shell (optional)
On the server side, configure the default ssh shell in the windows registry.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShell - Full path (case sensitive) of the shell executable
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShellCommandOption - The switch that the configured default shell requires to execute a command and immediately exit and return to the calling process. It is used for executing the remote ssh commands. Example- ssh user@ip hostname
If you are configuring the powershell.exe/cmd.exe/WSL-bash.exe as default ssh shell then you can ignore Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShellCommandOption. Your registry should look like this.
If you want to configure default shell (Ex- cygwin) other than powershell/cmd/WSL-bash then your registry should look like this
- Start Windows Powershell as Administrator
- Navigate to the OpenSSH directory
cd 'C:\Program Files\OpenSSH'
- Run the uninstall script
powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1
- MSI Install Instructions
- Script Install Instructions
- Alternative installation using the universal installer
- Retrieving download links for the latest packages