SSH Config File on Linux: ~/.ssh/config Examples (Host Aliases)

ssh config file linux - custom-sshcfg-featured.png

ssh config file linux queries want copy-paste ~/.ssh/config patterns — not another hardening essay. Hardening: OpenSSH hardening.

Create config with safe perms

Mode 600 on ~/.ssh/config and private keys.

bashperms
chmod 600 ~/.ssh/config
chmod 700 ~/.ssh
chmod
600

Simple Host alias

Map a short name to hostname, user, and key.

ssh-configprod
Host prod
  HostName 203.0.113.10
  User deploy
  IdentityFile ~/.ssh/id_ed25519_deploy
Host
alias

Jump host (ProxyJump)

Reach private hosts via bastion in one command.

ssh-configjump
Host db-internal
  HostName 10.0.2.50
  User dba
  ProxyJump bastion

Host bastion
  HostName jump.example.com
  User leap
ProxyJump
bastion

Defaults for all hosts

Host * block for ServerAliveInterval and identity.

ssh-configdefaults
Host *
  ServerAliveInterval 60
  IdentitiesOnly yes
Host *
defaults

Quick Reference

  • Connect: ssh prod
  • Keys: ssh-keygen + IdentityFile

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.