ssh command
Log in to remote servers and run commands over a secure connection.
- Networking
- Package openssh-client
- 8 options · 9 examples
Syntax
ssh [options] [user@]host [command]Provided by the openssh-client package. Run man ssh for the full manual.
Common options
| Option | What it does |
|---|---|
-p PORT | Connect to another port |
-i FILE | Use this private key |
-L L:host:R | Forward a local port |
-R R:host:L | Forward a remote port |
-D PORT | SOCKS proxy |
-J HOST | Jump through a bastion host |
-N | No remote command (for tunnels) |
-v | Verbose, for debugging |
Examples
Connect to a server
ssh user@192.0.2.10Use another port
ssh -p 2222 user@serverUse a specific key
ssh -i ~/.ssh/deploy_key user@serverRun one command
ssh user@server "df -h"Create a key pair
ssh-keygen -t ed25519 -C "you@example.com"Copy your key to a server
ssh-copy-id user@serverForward local port 8080 to the server's 80
ssh -N -L 8080:localhost:80 user@serverThrough a jump host
ssh -J bastion.example.com user@10.0.0.5Debug a connection
ssh -v user@server
No example matches. Check the options table or search the guides.
Tips
- Save host settings in
~/.ssh/configso you can typessh web1.
ssh guides
- 3 Simple Ways to Transfer Files Securely Over SSH Linux Commands · Updated Apr 2025
- SSHFS: Mounting a Remote File System over SSH Networking · Updated Apr 2025
- How to Download and Upload Files over SSH Networking · Updated Apr 2025
- How To Set Up SSH Keys in Linux Security · Updated Apr 2025
- How to Generate SSH Keys in PEM Format Networking · Updated Apr 2025
