CloudsArk
Commands Linux

ssh Command Examples in Linux

Practice useful ssh command examples for everyday Linux administration and troubleshooting.

ssh Command Examples in Linux

Introduction

These examples show practical ways to use ssh on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.

Example 1: Basic Usage

ssh admin@server.example.com

This is the simplest form of the command and is a good starting point before adding options.

Example 2: Common Admin Task

ssh admin@server.example.com hostname

This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.

Example 3: Useful Option

ssh -p 2222 admin@server.example.com

This option helps narrow the result, change behavior, or handle a more realistic target.

Example 4: Real-World Scenario

ssh -i ~/.ssh/id_rsa admin@server.example.com

Use this pattern when the task moves beyond a single basic command.

Example 5: Verification

ssh -V

Example output:

OpenSSH_9.6p1, OpenSSL 3.0.7 1 Nov 2022

Common Mistakes

  • Using the wrong remote username.
  • Leaving private key permissions too open.
  • Troubleshooting authentication without trying ssh -v for useful details.

Quick Reference

ssh admin@server.example.com
ssh admin@server.example.com hostname
ssh -p 2222 admin@server.example.com
ssh -i ~/.ssh/id_rsa admin@server.example.com
ssh -V

Summary

Good ssh usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.