SSH Cheat Sheet/Run a remote command

Execute one command remotely without opening an interactive shell.

Section: Basics

Run a remote command

bash
bash
ssh user@example.com 'uname -a'
Explanation

Execute one command remotely without opening an interactive shell.

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 Basics
Batch mode for automation
Disable password prompts for scripts and CI.
OpenIn sheetbashsame section
Run without allocating a TTY
Useful in non-interactive scripts.
OpenIn sheetbashsame section
Run a local script over SSH via stdin
Send a local script to the remote shell over standard input.
OpenIn sheetbashsame section
Connect to a host
Open an interactive SSH session.
OpenIn sheetbashsame section
Connect on a non-default port
Specify a custom SSH port.
OpenIn sheetbashsame section
Verbose output
Show extra connection and auth debugging details.
OpenIn sheetbashsame section