1 min read

SSH config tips for managing many servers


Stop typing long SSH commands

Add to ~/.ssh/config:

ssh_config
Host prod-web
    HostName 10.0.1.50
    User deploy
    IdentityFile ~/.ssh/prod_key
    ProxyJump bastion
 
Host bastion
    HostName bastion.example.com
    User admin
    IdentityFile ~/.ssh/bastion_key

Now just type:

ssh_alias.sh
ssh prod-web

Set defaults for all connections:

ssh_config_defaults
Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3
    AddKeysToAgent yes

Use wildcards for groups of hosts:

ssh_config_wildcard
Host dev-*
    User developer
    IdentityFile ~/.ssh/dev_key