ssh Command Generator — Connect, Tunnel & Run Commands
Build the exact ssh command — a plain connection, a port-forward tunnel, or
a remote command — with every flag explained. Or paste an ssh command to
decode it. Runs in your browser.
Your command
—
Or: decode an ssh command
Paste any ssh command — every flag gets explained.
The shape of an ssh command
At its simplest, ssh user@host opens a shell. From there you bolt on options: a
different port (-p), a specific key (-i), a tunnel (-L /
-R), or a command to run instead of an interactive shell. Put a command in quotes at the
end and ssh runs it remotely and returns the output — perfect for scripts.
Local vs remote tunnels, the part everyone re-googles
-L local:host:port(local forward) brings a remote service to you.-L 8080:localhost:80means "open 8080 on my machine; anything I send there pops out aslocalhost:80on the server." Use it to reach a database or admin panel that only listens on the server.-R remote:host:port(remote forward) is the mirror: it exposes your local service on the server. Use it to let a remote box reach something running on your laptop.- Add
-Nfor a pure tunnel. Without it you also get a shell;-Nsays "just hold the tunnel, don't run anything".
Gotchas worth knowing
- Key permissions matter. ssh refuses a private key that's readable by others —
it must be
600. (That's what the chmod 600 page is about.) -pfor ssh,-Pfor scp. A classic mix-up: the port flag is lowercase forsshbut uppercase forscpandsftp.- Repeated options live in
~/.ssh/config. Once a host's user, port and key are in your config,ssh myserveris all you need — no flags. - Jump through a bastion with
-J.ssh -J jump@bastion user@internalhops through the bastion to reach a host you can't connect to directly.
Frequently asked questions
How do I ssh with a specific key and port?
ssh -i ~/.ssh/id_ed25519 -p 2222 user@host. -i picks the key,
-p the port.
How do I create an SSH tunnel?
ssh -L 8080:localhost:5432 -N user@host forwards your local port 8080 to the server's
localhost:5432. Visit localhost:8080 to reach it.
How do I run a command over ssh without logging in?
Put the command in quotes: ssh user@host 'df -h' runs it remotely and prints the
output, then exits.
Why does ssh ignore my key file?
Usually permissions: the private key must be chmod 600. ssh refuses keys that other
users can read.
More shell tools: rsync, curl, chmod, or all on the home page.