SSH Command in Linux (original) (raw)

Last Updated : 1 Jun, 2026

SSH (Secure Shell) is a secure communication protocol that allows a user to access and control a remote computer over a network.

Basic Syntax of the SSH Command

To connect to a remote server, use:

ssh [username]@[hostname or IP address]

Here, Replace [username] with your remote server username, and [hostname or IP address] with the server's hostname or IP address.

Example:

ssh vboxuser@10.0.2.15

**Output:

image---2025-11-19T172157603

Installing SSH

To install SSH, you simply install the OpenSSH package, which provides both the client and server components.

On Ubuntu/Debian:

sudo apt update
sudo apt install openssh-client openssh-server

On CentOS/Fedora/RHEL:

sudo dnf install openssh-clients openssh-server

Start and enable the SSH service:

sudo systemctl start sshd
sudo systemctl enable sshd

Check status:

sudo systemctl status sshd

**Output:

image---2025-11-19T174109287

Given below the examples by using SSH Command.

Example 1: Connect to a Remote Server Using SSH

ssh vboxuser@10.0.2.15

**Output:

image---2025-11-19T172157603

Example 2: Using SSH Key Authentication

SSH keys offer better security than passwords.

ssh-keygen

ssh-copy-id username@server_ip

ssh username@server_ip

image---2025-11-19T174718712

Common SSH Options

These options help troubleshoot issues, improve performance, and customize the connection.

Option Purpose Example
-p Connect to a custom SSH port ssh -p 2222 user@host
-v Enable detailed debugging output ssh -v user@host
-C Enable compression ssh -C user@host
-4 Force IPv4 ssh -4 user@host
-6 Force IPv6 ssh -6 user@host
-X Forward GUI applications ssh -X user@host

Before You Connect: Requirements

To successfully connect to a remote Linux machine using SSH, ensure the following:

How SSH Secures Communication

SSH uses multiple layers of cryptography: