Skip to Content

~/.ssh/config — names instead of addresses

The OpenSSH client (Windows PowerShell, Linux, macOS, Git) reads ~/.ssh/config — on Windows C:\Users\you\.ssh\config with no file extension. Each Host block gives a short name its address, user and key.

Host lab
    HostName 203.0.113.10
    User student
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 30

Host *.bp-lab.example
    User student
    IdentityFile ~/.ssh/id_ed25519

Now ssh lab, scp file.txt lab: and git clone over SSH all use those settings. ssh -G shows what OpenSSH resolved — a real run:

ssh -G lab prints the final settings for a host — the quickest way to debug a config file.
ssh -G lab prints the final settings for a host — the quickest way to debug a config file.

Useful options

#OptionWhat it does
1Port 2222Non-standard SSH port
2ProxyJump bastionReach an inside server through a jump host in one command
3LocalForward 15432 127.0.0.1:5432Tunnel: your PC's port 15432 reaches PostgreSQL on the server
4IdentitiesOnly yesOffer only the listed key (avoids “too many authentication failures”)

WinSCP can import these hosts: Tools → Import Sites → OpenSSH config; it offers to convert the IdentityFile key to .ppk.

Try it — config file

  1. Create the config file with a lab entry.
  2. Run ssh lab hostname from PowerShell.
  3. Run ssh -G lab | findstr /b "hostname user port".
Rating
0 0

There are no comments for now.

to be the first to leave a comment.