SSH Cheat Sheet/Run a local command after connect

Execute a client-side command when the connection is established.

Section: Useful Options

Run a local command after connect

bash
bash
ssh -o PermitLocalCommand=yes -o LocalCommand='echo connected to %n' user@example.com
Explanation

Execute a client-side command when the connection is established.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Useful Options
Enable compression
Compress traffic for slower links.
OpenIn sheetbashsame section
Set connect timeout
Fail quickly if the host is unreachable.
OpenIn sheetbashsame section
Configure keepalives
Send keepalive probes to keep long sessions open.
OpenIn sheetbashsame section
Disable escape character
Prevent ~ escape handling in raw sessions.
OpenIn sheetbashsame section
Connect to a host
Open an interactive SSH session.
OpenIn sheetbash1 tag match
Use a specific private key
Choose a private key explicitly.
OpenIn sheetbash1 tag match