Launching an SSH login right into tmux

Topics: Secure Shell

This snippet starts an SSH login inside a tmux session by configuring the shell’s login script.

Add the following code to your ~/.zlogin file:

# Relaunch SSH session in tmux
if which tmux >/dev/null && [[ -z "$TMUX"  ]] && [[ -n "$SSH_CONNECTION" ]]; then
  exec tmux new -A -s $(whoami)
fi