SSH Cheat Sheet/Connect on a non-default port

Specify a custom SSH port.

Section: Basics

Connect on a non-default port

bash
bash
ssh -p 2222 user@example.com
Explanation

Specify a custom SSH port.

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
Connect to a host
Open an interactive SSH session.
OpenIn sheetbashsame section
Run a remote command
Execute one command remotely without opening an interactive shell.
OpenIn sheetbashsame section
Verbose output
Show extra connection and auth debugging details.
OpenIn sheetbashsame section
Very verbose output
Show full handshake and config debugging details.
OpenIn sheetbashsame section
Show SSH version
Print the local client version.
OpenIn sheetbashsame section
Batch mode for automation
Disable password prompts for scripts and CI.
OpenIn sheetbashsame section