Skip to main content

Command referencessh

ssh command (Linux / bash / sh / zsh)

Linuxbashshzshnetworkbeginner

What it does

Open a secure remote shell or run a command over SSH. When people search for the ssh command linux connection, they usually want ssh's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Open a secure remote shell or run a command over SSH.

Syntax

ssh [OPTION]... [USER@]HOST [COMMAND]

Common options

Flag / optionMeaning
-p PORTConnect to a nondefault port.
-i FILEUse a specific private key.
-L SPECCreate local port forwarding.
-J HOSTConnect through a jump host.
-vPrint connection diagnostics.

Practical examples

Remote shell

ssh admin@server.example.com

Opens an encrypted login session.

Use key

ssh -i ~/.ssh/work_ed25519 admin@server

Authenticates with a selected key.

Run command

ssh server 'uptime'

Runs uptime remotely and returns its output.

Common mistakes

  • Accepting an unexpected changed host key without verifying the server.
  • Making private key files readable by other users.

FAQ

What does ssh do in Linux?

Open a secure remote shell or run a command over SSH.

How do I use ssh from the terminal?

Start with `ssh [OPTION]... [USER@]HOST [COMMAND]`, then choose only the options needed for the task.

What is a practical ssh example?

Try `ssh admin@server.example.com` — Opens an encrypted login session.

Can I use ssh in a shell script?

Yes. ssh works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.