What it does
Builds a Host block for the OpenSSH client config file ~/.ssh/config. With an alias you stop typing the address, user, port, key, bastion and forwards every time. Empty fields are left out; values ssh might not read the way you expect (an alias with spaces, a path containing %, …) produce no block and a reason next to the field.
Examples
| You want | Lines in the block |
|---|---|
| Port 2222 with a specific key | Port 2222 · IdentityFile ~/.ssh/id_ed25519 · IdentitiesOnly yes |
| Reach an internal server through a bastion | ProxyJump admin@bastion.example.com:22 |
| The server's PostgreSQL on your port 5433 | LocalForward 5433 localhost:5432 |
| Your dev server on 3000 as the server's 9000 | RemoteForward 9000 localhost:3000 |
| A SOCKS proxy for the browser | DynamicForward 1080 |
| Idle connections that drop | ServerAliveInterval 60 · ServerAliveCountMax 3 |
Common mistakes
- **
Host *at the top — for each setting ssh uses the first value it finds**. AUser rootunderHost *at the top wins over theUserin later blocks. Put shared defaults at the end of the file. - A config file others can write — ssh refuses it with "Bad owner or permissions". Keep it
chmod 600. - Too many keys — with several keys in the agent, ssh offers them one by one and hits the server's limit. Use
IdentitiesOnly yestogether withIdentityFile.
How it was checked
Before publishing, 32 generated blocks were read back with OpenSSH 9.6p1 ssh -G -F <temp file> <alias> (prints the final settings and exits without connecting), 99 checks in total. A Host * block was appended to confirm the specific block wins, empty fields were checked to fall back to the defaults (port 22, alias as the address), and invalid input was confirmed to produce no block.
FAQ
Can I check the config without connecting?
ssh -G alias prints the final settings for that alias and exits. Filter what you need: ssh -G myserver | grep -E '^(hostname|user|port|identityfile) '.
What is the difference between ProxyJump and ForwardAgent?
ProxyJump uses the bastion only as a tunnel; authentication to the target happens from your machine. ForwardAgent lends your agent to the server, so its administrator can use your keys elsewhere while you are connected. To hop through a bastion, use ProxyJump.
Is what I type sent to a server?
No. The block is built in your browser. Addresses, user names and paths are not sent to a server and are not passed to the analytics or ads this site uses. See the privacy notice.