SSH Explained: A Visual Guide for Absolute Beginners

Learn how SSH works and how to use it securely - from your first connection to advanced tunnels

SSH Explained: A Visual Guide for Absolute Beginners
📧

Get weekly IT guides

Join 5,000+ IT professionals

Subscribe Free

seriesOrder: 3 prerequisites: [] resources:


What if you could control any computer in the world from your couch?

That’s exactly what SSH lets you do. Securely.

Whether it’s a server in a data center 5,000 miles away or a Raspberry Pi in your closet, SSH gives you a secure tunnel to control it as if you were sitting right in front of it.

By the end of this guide, you’ll:

  • ✅ Understand what SSH is (and why it matters)
  • ✅ Connect to your first remote server
  • ✅ Set up secure key-based authentication
  • ✅ Never type a password again

Let’s begin.


The Analogy: Your Secret Telephone Booth

Mental Model

Imagine a magical telephone booth that appears only for you.

When you step inside:

  • Nobody can hear your conversation (it’s encrypted)
  • Only you have the key to enter (that’s authentication)
  • You can talk to any telephone booth in the world (that’s the server)

SSH is that booth. It creates a secret, encrypted tunnel between your computer and another computer. Anyone watching the network sees only scrambled nonsense.

SSH Secure Tunnel Diagram
The SSH Encrypted Tunnel

The Big Picture: How SSH Works

SSH Secure Tunnel Diagram showing client-server encrypted channel
The SSH Encrypted Tunnel: Your machine and the server communicate through an encrypted channel

Here’s what happens when you type ssh user@server:

  1. Your computer (the “client”) knocks on the server’s door (port 22)
  2. The server responds with its identity (host key)
  3. You verify the server is who it claims to be
  4. Authentication happens (password or key)
  5. Encrypted tunnel is established
  6. You’re in! Everything you type is encrypted

How SSH Encryption Actually Works

Most tutorials skip this part — but understanding the crypto is what separates someone who uses SSH from someone who truly understands it.

SSH uses a two-phase encryption strategy:

Phase 1: The Handshake (Asymmetric Encryption)

When you first connect, SSH needs to securely agree on a shared secret — without ever sending it over the network. It uses ECDH (Elliptic Curve Diffie-Hellman):

StepWhat Happens
1. Client HelloYour machine announces the SSH version and supported algorithms
2. Server IdentityServer sends its host key (its permanent public identity)
3. Key ExchangeBoth sides independently compute the same session key using ECDH math
4. VerificationYour client checks the host key against ~/.ssh/known_hosts
5. Tunnel OpensThe shared session key is activated — encrypted tunnel is live
The Magic of ECDH

Both sides compute the same session key without ever transmitting it across the network. Even if someone recorded every byte of your connection, they cannot derive the key. This is called perfect forward secrecy — each session uses a unique, temporary key that is discarded after the session ends.

Phase 2: The Session (Symmetric Encryption)

Once the tunnel is open, SSH switches to symmetric encryption (typically AES-256-CTR or ChaCha20). Why the switch?

  • Asymmetric (ECDH): Secure key exchange, but ~1,000x slower
  • Symmetric (AES-256): Requires a pre-shared key, but blazing fast

The result: asymmetric crypto secures the handshake. Symmetric crypto handles every keystroke, every file, every command — efficiently.

SSH vs HTTPS: Which is More Secure?

Both use the same two-phase approach. The key difference: SSH permanently records the server’s host key in ~/.ssh/known_hosts on first connect, so you’d be warned if it ever changes. HTTPS trusts any certificate from a recognised CA. SSH’s server identity verification is actually stricter.


Prerequisites

Before we start, you need:

RequirementWhyHow to Check
A terminalTo type commandsOpen Terminal (Mac/Linux) or PowerShell (Windows)
A server to connect toSomething to SSH intoAWS free tier, DigitalOcean, home Raspberry Pi
SSH installedUsually pre-installedRun ssh -V to check
Don't have a server?

No worries! You can practice with:

  • Free: AWS EC2 free tier (12 months)
  • Cheap: DigitalOcean droplet ($4/month)
  • Free + Fun: Raspberry Pi at home

Step 1: Your First SSH Connection

Let’s connect to a server. This is the moment you become a remote wizard.

ssh

Connect to a remote server

beginner
ssh [username]@[server-ip-or-hostname]
ssh admin@192.168.1.100
Welcome to Ubuntu 24.04.1 LTS
Last login: Sat Feb 9 10:15:32 2026
admin@server:~$
  • Replace 'admin' with your actual username
  • Replace the IP with your server's address
  • First connection will ask you to verify the host

What Happens Next?

The first time you connect, you’ll see something like:

The authenticity of host '192.168.1.100' can't be established.
ED25519 key fingerprint is SHA256:xYz123...
Are you sure you want to continue connecting (yes/no)?
This is Important!

This message means your computer doesn’t recognize this server yet.

Type yes if:

  • You trust the server (it’s yours or your company’s)
  • You’re on a secure network

Be careful if:

  • You’re on public WiFi
  • You’re connecting to an unknown server

This protects you from “man-in-the-middle” attacks where someone pretends to be your server.

After typing yes, it’s saved. You won’t see this again for this server.

🎉 Congratulations! You just made your first SSH connection!


Step 2: SSH Keys — Never Type a Password Again

Passwords are annoying. And risky. Let’s upgrade to SSH keys.

Mental Model

Think of SSH keys like:

  • Public key = A lock you put on the server’s door
  • Private key = The unique key only you have

You give the server your lock (public key). Only your key (private key) can open it. Even if someone steals the lock, they can’t open the door without your key.

Step 2.1: Generate Your Key Pair

ssh-keygen

Generate a new SSH key pair

beginner
ssh-keygen -t ed25519 -C 'your_email@example.com'
ssh-keygen -t ed25519 -C 'shekhar@shekharit.com'
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/you/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Your identification has been saved in /home/you/.ssh/id_ed25519
Your public key has been saved in /home/you/.ssh/id_ed25519.pub
  • Press Enter to accept the default location
  • Add a passphrase for extra security (recommended)
  • ED25519 is the most secure and modern algorithm

This creates two files:

  • ~/.ssh/id_ed25519 — Your private key (NEVER share this!)
  • ~/.ssh/id_ed25519.pub — Your public key (safe to share)

Step 2.2: Copy Your Public Key to the Server

ssh-copy-id

Install your public key on a remote server

beginner
ssh-copy-id [username]@[server]
ssh-copy-id admin@192.168.1.100
Number of key(s) added: 1
Now try logging into the machine with: ssh admin@192.168.1.100
  • You'll need to enter your password one last time
  • This adds your key to ~/.ssh/authorized_keys on the server

Step 2.3: Test It!

Now connect again — no password needed:

ssh admin@192.168.1.100

🎉 You’re in! No password prompt. Magic.


Troubleshooting: When Things Go Wrong

ProblemCauseSolution
Connection refusedSSH server not runningRun sudo systemctl start sshd on server
Permission deniedWrong key or no accessCheck key, verify user exists
Connection timed outNetwork/firewall issueCheck server’s firewall (port 22)
Host key verification failedServer changed its keyRemove old key with ssh-keygen -R [host]
If Your Key Gets Compromised

If someone steals your private key:

  1. Generate a new key immediately
  2. Remove the old public key from all servers
  3. Add your new public key to servers

Never share your private key with anyone. Ever.



Step 3: The SSH Config File — Your Shortcut System

Typing ssh ubuntu@54.23.88.101 -p 2222 -i ~/.ssh/id_production every time is painful. The SSH config file fixes this permanently.

Create ~/.ssh/config:

Host myserver
    HostName 192.168.1.100
    User admin
    Port 22
    IdentityFile ~/.ssh/id_ed25519

Host prod
    HostName 54.23.88.101
    User ubuntu
    Port 2222
    IdentityFile ~/.ssh/id_production

Now connecting is just:

ssh myserver

SSH connects using all settings from ~/.ssh/config automatically

beginner
  • Tab-completion works for Host names in some shells
  • Use '*' as a wildcard to apply settings to all hosts
  • Run 'man ssh_config' to see all 60+ options
Set Correct Permissions

SSH will refuse to use your config file if permissions are too open:

chmod 600 ~/.ssh/config


File Transfers: SCP and SFTP

SSH isn’t only for terminal sessions — it also powers secure file transfers.

SCP (Secure Copy — Fast and Simple)

scp

Copy files securely between local and remote machines

beginner
scp [source] [user@host:destination]
scp report.pdf ubuntu@192.168.1.100:/home/ubuntu/
  • Use -r to copy entire directories recursively
  • Reverse it to download: scp ubuntu@server:/path/file.txt .
  • Use -P (capital P) to specify a non-standard port

SFTP (SSH File Transfer Protocol — Interactive)

SFTP replaced FTP entirely — it runs over SSH so it is encrypted by default. Useful for interactive file browsing on a server:

sftp ubuntu@192.168.1.100

Open an interactive encrypted file transfer session

beginner
  • Type 'help' for all available commands
  • 'put file.txt' uploads, 'get file.txt' downloads
  • GUI tools like FileZilla and Cyberduck support SFTP

Hardening SSH (Security Best Practices)

Once keys are working, lock your server down further. Edit /etc/ssh/sshd_config:

1. Disable Password Authentication

# In /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin no
PubkeyAuthentication yes

2. Restrict Which Users Can Log In

# Only 'ubuntu' and 'deploy' users can SSH in
AllowUsers ubuntu deploy

3. Protect Against Brute Force with fail2ban

fail2ban automatically bans IPs that fail authentication repeatedly:

sudo apt install fail2ban

Install fail2ban — automatically blocks brute-force SSH attacks

intermediate
  • After install, the SSH jail is active by default
  • Default: 5 failed attempts → 10-minute IP ban
  • Check bans with: sudo fail2ban-client status sshd
Always Test Before Closing Your Session

After editing sshd_config, restart SSH with sudo systemctl restart sshd, then open a second terminal and verify you can still connect. A misconfigured sshd can permanently lock you out of your server.


SSH Tunneling: Port Forwarding

SSH tunnels let you securely forward network traffic through an encrypted channel. This is one of SSH’s most powerful — and underused — features.

Local Port Forwarding — tunnel a remote service to your local machine:

ssh -L 8080:localhost:80 ubuntu@server

Forward local port 8080 to port 80 on the remote server

intermediate
  • After this, http://localhost:8080 connects to the server's port 80
  • Useful for accessing internal dashboards securely
  • Use -N to create the tunnel without opening a shell
SSH Port Forwarding Diagram showing local-to-remote traffic tunnelling
SSH Port Forwarding: Tunnelling a remote service through an encrypted SSH channel

🧠 Test Your Knowledge

🧠

SSH Mastery Check

Take a quick 4-question quiz to check your understanding.


Key Takeaways

  • What SSH is: An encrypted tunnel for remote control, file transfers, and port forwarding
  • Two-phase encryption: Asymmetric ECDH for the handshake → Symmetric AES-256 for the session
  • Key-based auth: ssh-keygen -t ed25519ssh-copy-id user@server → passwordless login
  • SSH config: ~/.ssh/config for shortcuts; chmod 600 ~/.ssh/config for safety
  • File transfers: scp for quick copies, sftp for interactive sessions
  • Hardening: Disable passwords, restrict users, install fail2ban
  • Port forwarding: ssh -L to tunnel remote services through the encrypted channel

Found this helpful? Explore more in the Linux Hub!

📧

Get weekly IT guides

Join 5,000+ IT professionals

Subscribe Free
Type to start searching...