Archive · Linux

Quality of Life: ~/.ssh/config and tmux

Short names for servers, and sessions that survive a dropped connection.

1 min read

  • Ubuntu 18.04.4 LTS
  • OpenSSH 7.6
  • tmux 2.6

Stop typing long SSH commands. In ~/.ssh/config:

Host web1
    HostName 203.0.113.10
    User deploy
    IdentityFile ~/.ssh/id_ed25519

Host *.internal
    ProxyJump bastion

Now ssh web1 works, and ProxyJump (OpenSSH 7.3 and later) reaches private hosts through a bastion without extra steps.

For long-running work, use tmux so a lost connection does not kill your task:

tmux new -s upgrade        # start a named session
# Ctrl+b then d             detach
tmux ls
tmux attach -t upgrade     # come back later

Useful keys after the Ctrl+b prefix: % splits vertically, " splits horizontally, arrow keys move between panes. Start every long package upgrade or data copy inside tmux.