# sshLog in to a server
Syntax ssh [options] user@host
> ssh deploy@203.0.113.10CMD Copy
Log in as deploy
> ssh -p 2222 deploy@example.comCMD Copy
Different port
> ssh -i %USERPROFILE%\.ssh\id_ed25519 deploy@example.comCMD Copy
Use a specific key
> ssh deploy@example.com "df -h"CMD Copy
Run one command and come back
> ssh -J jump@bastion.example.com deploy@10.0.0.5CMD Copy
Through a jump host
Tip If ssh is not found, open Settings, Apps, Optional features, and add OpenSSH Client.
# ssh-keygenMake a key pair
Syntax ssh-keygen [options]
> ssh-keygen -t ed25519 -C "me@example.com"CMD Copy
Create a key; it is saved in C:\Users\you\.ssh
> ssh-keygen -lf %USERPROFILE%\.ssh\id_ed25519.pubCMD Copy
Show the fingerprint
# Install the key on a serverThere is no ssh-copy-id on Windows
Syntax PowerShell
# ssh-agentRemember passphrases
Syntax ssh-add [key]
PS> Get-Service ssh-agent | Set-Service -StartupType AutomaticPowerShell Copy
Allow the agent to start (administrator)
PS> Start-Service ssh-agentPowerShell Copy
Start it
> ssh-add %USERPROFILE%\.ssh\id_ed25519CMD Copy
Unlock the key once
# scpCopy files over SSH
Syntax scp source destination
> scp report.pdf deploy@example.com:/home/deploy/CMD Copy
Upload
> scp deploy@example.com:/var/log/app.log .CMD Copy
Download
> scp -r site deploy@example.com:/var/www/CMD Copy
A whole folder
> scp C:\Data\file.zip deploy@example.com:~CMD Copy
Windows path as the source
# sftpInteractive transfer
Syntax sftp user@host
# ssh tunnelsForward ports
Syntax ssh -L / -R / -D
> ssh -L 5432:127.0.0.1:5432 deploy@example.comCMD Copy
Reach the server's database at localhost:5432
> ssh -D 1080 deploy@example.comCMD Copy
A SOCKS proxy at localhost:1080
# config fileShortcuts for servers
Syntax C:\Users\you\.ssh\config
> Host webCMD Copy
A line in the config file
> HostName 203.0.113.10CMD Copy
Add the address on the next line
> User deployCMD Copy
and the user; now just type: ssh web
# Get-WindowsCapabilityInstall OpenSSH
Syntax Add-WindowsCapability
PS> Get-WindowsCapability -Online | Where Name -like 'OpenSSH*'PowerShell Copy
See if it is installed
PS> Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0PowerShell Copy
Install the client (administrator)
PS> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0PowerShell Copy
Install the server, if you want to log in to this PC
# sshdRun an SSH server on Windows
Syntax Start-Service sshd
Tip Allow port 22 in the firewall, then connect with SSH Command from another computer.