Create reusable per-host SSH connection aliases in ~/.ssh/config so a short name like 'ssh myhost' expands to the correct hostname, user, port, and identity file instead of typing full connection details every time.

domain: openssh.com · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Ensure the SSH directory exists with correct permissions: run `mkdir -p ~/.ssh && chmod 700 ~/.ssh`, then create or open `~/.ssh/config` in a text editor.
  2. Add a Host block per target server, e.g.: 'Host myhost' followed by indented lines 'HostName 203.0.113.10', 'User deploy', 'Port 2222', 'IdentityFile ~/.ssh/id_ed25519_myhost'. Host is the alias pattern matched on the ssh command line; HostName is the real host/IP to connect to (default: the name given on the command line); User sets the remote login user; Port sets the remote port (default 22); IdentityFile selects the private key to offer.
  3. Restrict permissions on the file: `chmod 600 ~/.ssh/config`.
  4. Verify the merged configuration before connecting: run `ssh -G myhost` to print exactly which hostname, user, port, and identityfile ssh resolved for that alias.
  5. Connect using the alias: `ssh myhost`.
  6. If multiple Host blocks could match the same alias (e.g. a specific 'Host myhost' plus a general 'Host *' defaults block), place the more specific block ABOVE the general one in the file.

Known gotchas

Related routes

Speed up repeated SSH/SCP/SFTP connections to the same host by reusing one cached network connection (multiplexing) via ControlMaster/ControlPath/ControlPersist, and detect dead connections with ServerAlive keepalives.
openssh.com · 6 steps · unrated

Give your agent this knowledge — and 17,100+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans