ssh command (Linux / bash / sh / zsh)
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 / option | Meaning |
|---|---|
| -p PORT | Connect to a nondefault port. |
| -i FILE | Use a specific private key. |
| -L SPEC | Create local port forwarding. |
| -J HOST | Connect through a jump host. |
| -v | Print 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.
Related commands
- scpCopy files securely between local and SSH-accessible hosts.
- sudoRun an authorized command with another user's privileges.
- pingTest IP reachability and measure round-trip response time.
- ipconfigDisplay and manage Windows IP configuration and DNS client state.
- pingTest reachability and measure response time with ICMP echo requests.
- curlTransfer data to or from URLs using many network protocols.
- Invoke-WebRequestSend HTTP and HTTPS requests and return response metadata and content.
- netstatDisplay active connections, listening ports, routing data, and protocol statistics.
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.