ssh flags & options
-p
Connect to a specific port instead of the default 22.
ssh -p 2222 user@host
-i
Use a specific private key file for authentication.
ssh -i ~/.ssh/mykey user@host
-L
Forward a local port to a remote address through the SSH tunnel.
ssh -L 8080:localhost:80 user@host
ssh -L 3306:db.internal:3306 user@bastion
-R
Forward a remote port back to a local address.
ssh -R 9090:localhost:3000 user@host
-D
Create a SOCKS proxy on a local port.
ssh -D 1080 user@host
-N
Don't execute a remote command. Useful for port forwarding only.
ssh -N -L 8080:localhost:80 user@host
-f
Go to background just before command execution.
ssh -f -N -L 8080:localhost:80 user@host
-v
Verbose mode. Shows debugging info. Use -vv or -vvv for more detail.
ssh -v user@host
-A
Enable forwarding of the SSH agent. Lets you use your local keys on the remote host.
ssh -A user@bastion
-J
Jump through a proxy/bastion host (ProxyJump).
ssh -J bastion user@internal-host
-t
Force pseudo-terminal allocation. Useful for running interactive commands.
ssh -t user@host top
-o
Set an SSH option directly on the command line.
ssh -o StrictHostKeyChecking=no user@host
ssh -o ConnectTimeout=5 user@host