Reuse SSH connections (ControlMaster)

Later SSH commands reuse the open connection; it stays alive 10 minutes after you exit

ssh -o ControlMaster=auto -o ControlPath=~/.ssh/mux-%r@%h:%p -o ControlPersist=10m user@host

tool
ssh15 commands
tags
sshperformance

More ssh commands

  • ssh user@host 'sudo systemctl status nginx'

    Run a command over SSH without an interactive shell

  • scp -r -P 2222 ./dist/ user@host:/var/www/app/

    Copy recursively to a server on a non-standard port

  • ssh -A user@bastion

    Forward your local SSH agent to the remote host; use with care

  • eval $(ssh-agent) && ssh-add ~/.ssh/id_ed25519

    Start the agent and load a key for this session

  • cat >> ~/.ssh/config <<'EOF' Host dev HostName 10.0.0.5 User ubuntu IdentityFile ~/.ssh/dev_key ProxyJump bastion EOF

    Short alias: "ssh dev" applies all these options

all 15 ssh commands