SSH Learning
SSH Basics
SSH Topic #1 β What is SSH?
Level: Beginner β Intermediate Foundation
Before learning keys, tunnels, certificates, or SSH internals, you must understand what SSH is, why it exists, and what problem it solves.
Table of Contents
- What is SSH?
- Why SSH Was Created
- History of SSH
- Problems with Telnet
- Secure Communication Concepts
- SSH Architecture Overview
- Internal Working of SSH
- SSH Use Cases
- Basic Commands
- Real-World Examples
- Production Examples
- Common Mistakes
- Troubleshooting
- Security Notes
- Interview Questions
- Hands-On Labs
- Exercises
- Quiz
1. What is SSH?
SSH stands for:
Secure Shell
SSH is a cryptographic network protocol used to securely communicate with remote systems over an untrusted network.
Most commonly used for:
β Remote Login
β Server Administration
β File Transfer
β Secure Tunneling
β Automation
β DevOps Operations
Example:
ssh [email protected]
Meaning:
Connect securely to a remote machine
using the username "ubuntu"
at IP address 192.168.1.10
Simple Definition
Imagine:
You are sitting at home.
A Linux server is running in another city.
SSH allows you to securely open
a terminal on that remote server
and control it as if you were sitting
in front of it.
2. Why SSH Was Created
Before SSH existed, people used:
Telnet
rlogin
rsh
These protocols were insecure.
Major problem:
Everything was sent in plain text.
Example:
Username: admin
Password: secret123
An attacker monitoring the network could read:
admin
secret123
directly.
Real Problem
Imagine:
Laptop
|
Internet
|
Server
An attacker sitting anywhere between:
Laptop ---- Hacker ---- Server
could capture:
Username
Password
Commands
Sensitive Data
SSH Solution
SSH introduced:
Encryption
Authentication
Integrity Verification
Now network traffic looks like:
akd82jskd92ksk292jskdj
3kdkdk393kdk29dkd923
xj2838dksk2992jjd
instead of readable text.
3. History of SSH
1995
A researcher named:
Tatu YlΓΆnen
created SSH.
Reason:
A password-sniffing attack
occurred on a university network.
He wanted a secure replacement for Telnet.
SSH-1
First version:
SSH-1
Problems:
Security weaknesses
Protocol limitations
SSH-2
Modern version:
SSH-2
Current standard.
Almost all systems today use:
SSH-2
SSH Timeline
1995 SSH-1 Created
1996 Adoption Begins
2000 SSH-2 Released
Today OpenSSH Dominates
4. Problems with Telnet
Telnet was widely used before SSH.
Connection:
telnet server.example.com
How Telnet Works
Client
|
Plain Text
|
Server
Example
User enters:
username: admin
password: mypassword
Network capture:
username: admin
password: mypassword
Anyone monitoring traffic can see it.
Telnet Security Problems
Problem 1
No Encryption
Everything visible
Problem 2
No Authentication Protection
Credentials exposed
Problem 3
No Integrity Checking
Attackers may modify traffic.
Problem 4
Session Hijacking
Attackers can steal sessions.
Telnet vs SSH
| Feature | Telnet | SSH |
|---|---|---|
| Encryption | No | Yes |
| Secure Login | No | Yes |
| Integrity Check | No | Yes |
| Authentication | Weak | Strong |
| Production Usage | Rare | Standard |
5. Secure Communication Concepts
To understand SSH, learn these 3 concepts.
Concept 1: Confidentiality
Meaning:
Only intended parties
can read the data.
Achieved using:
Encryption
Concept 2: Integrity
Meaning:
Data was not modified
during transmission.
Example:
Original:
Transfer $100
Modified:
Transfer $1000
Integrity checks detect this.
Concept 3: Authentication
Meaning:
Verify identity.
Questions:
Is this really the server?
Is this really the user?
SSH verifies both.
CIA Model
SSH helps provide:
C = Confidentiality
I = Integrity
A = Authentication
6. SSH Architecture Overview
High-level architecture:
+------------+
| SSH Client |
+------------+
|
|
Encrypted Channel
|
|
+------------+
| SSH Server |
+------------+
Components
SSH Client
Program:
ssh
Initiates connection.
SSH Server
Program:
sshd
Accepts connections.
Secure Channel
Encrypted communication tunnel.
Example
ssh user@server
Client:
ssh
Server:
sshd
7. Internal Working of SSH
Let's simplify the entire process.
Step 1
Client Starts Connection
ssh user@server
Step 2
TCP Connection Created
Default Port:
22
Step 3
Protocol Version Exchange
Example:
SSH-2.0-OpenSSH_9.8
Step 4
Server Identity Verification
Server presents:
Host Key
Step 5
Key Exchange
Client and server generate:
Temporary Session Key
Step 6
Encrypted Tunnel Created
Client <====Encrypted====> Server
Step 7
User Authentication
Methods:
Password
Public Key
Certificate
Step 8
Shell Session Starts
User receives:
user@server:~$
Complete Flow Diagram
Client
|
| TCP Connection
|
Server
|
Version Exchange
|
Host Verification
|
Key Exchange
|
Encryption Enabled
|
Authentication
|
Interactive Shell
8. SSH Use Cases
Use Case 1
Remote Administration
ssh admin@server
Manage Linux servers remotely.
Use Case 2
File Transfer
Using:
scp
or
sftp
Use Case 3
Git Operations
git clone [email protected]:user/repo.git
Use Case 4
DevOps Automation
ssh server "systemctl restart nginx"
Use Case 5
Database Access
ssh -L
Port forwarding.
Use Case 6
Cloud Management
AWS EC2
Azure VM
Google Cloud VM
9. Commands
Check version:
ssh -V
Connect:
ssh user@server
Specify Port:
ssh -p 2222 user@server
Verbose Mode:
ssh -v user@server
Very Verbose:
ssh -vvv user@server
10. Code Examples
Connect to server:
ssh [email protected]
Execute command remotely:
ssh [email protected] "uptime"
List files remotely:
ssh [email protected] "ls -la"
Restart service remotely:
ssh [email protected] "sudo systemctl restart nginx"
11. Real-World Examples
Example:
A company has:
100 Linux servers
Administrators use SSH daily.
Tasks:
Check logs
Deploy software
Restart services
Manage users
All performed through SSH.
12. Production Examples
Example:
AWS EC2 Instance
Developer Laptop
|
|
SSH
|
|
AWS EC2 Server
Common production workflow:
ssh ubuntu@ec2-ip
Example:
CI/CD Pipeline
GitHub
|
Pipeline
|
SSH
|
Production Server
Deployment performed automatically.
13. Common Mistakes
Mistake 1
Using Telnet instead of SSH
Bad:
telnet server
Good:
ssh user@server
Mistake 2
Using Root Everywhere
Bad:
ssh root@server
Prefer:
ssh admin@server
Mistake 3
Ignoring Host Verification Warnings
Danger:
Possible MITM Attack
Mistake 4
Using Weak Passwords
Bad:
password123
14. Troubleshooting
Connection Refused
Reason:
SSH service not running
Check:
sudo systemctl status ssh
Connection Timed Out
Possible:
Firewall
Wrong IP
Network issue
Permission Denied
Possible:
Wrong username
Wrong password
Key issue
Host Key Verification Failed
Fix:
ssh-keygen -R server-ip
15. Security Notes
Always:
Use SSH instead of Telnet
Prefer:
Public Key Authentication
over passwords.
Verify host fingerprints.
Disable:
Root Login
Password Authentication
when appropriate.
Keep OpenSSH updated.
16. Interview Questions
Q1:
What is SSH?
Answer:
A secure protocol used for encrypted remote communication.
Q2:
Why was SSH created?
Answer:
To replace insecure protocols
such as Telnet.
Q3:
What port does SSH use?
Answer:
22
Q4:
What security properties does SSH provide?
Answer:
Confidentiality
Integrity
Authentication
Q5:
What process runs the SSH server?
Answer:
sshd
17. Hands-On Labs
Lab 1
Check SSH Version
ssh -V
Goal:
Verify SSH client installed.
Lab 2
Inspect SSH Service
sudo systemctl status ssh
Goal:
Verify server service exists.
Lab 3
Connect to Local VM
ssh user@vm-ip
Goal:
Experience first SSH login.
Lab 4
Use Verbose Mode
ssh -v user@server
Goal:
Observe connection process.
18. Exercises
Exercise 1:
Explain why Telnet is insecure.
Exercise 2:
Describe the difference between
SSH client and SSH server.
Exercise 3:
List three real-world SSH uses.
Exercise 4:
Draw the SSH connection flow.
Exercise 5:
Explain confidentiality,
integrity, and authentication.
19. Quiz
Question 1
SSH stands for:
A. Secure Session Host
B. Secure Shell
C. Security Shell Handler
D. Shell Security Host
Answer:
B
Question 2
Default SSH port:
A. 21
B. 22
C. 23
D. 80
Answer:
B
Question 3
Which protocol did SSH replace?
A. HTTPS
B. FTP
C. SMTP
D. Telnet
Answer:
D
Question 4
Which property prevents others from reading data?
A. Authentication
B. Integrity
C. Confidentiality
D. Availability
Answer:
C
Question 5
Which process usually handles SSH connections?
A. sshd
B. sshc
C. shelld
D. netd
Answer:
A
Summary
You should now understand:
β What SSH is
β Why SSH exists
β History of SSH
β Problems with Telnet
β Confidentiality
β Integrity
β Authentication
β SSH Architecture
β SSH Workflow
β Common Use Cases
β Basic Commands
β Troubleshooting Basics
Next Topic:
Topic #2 β SSH Architecture
Client
Server
sshd
Channels
Transport Layer
Authentication Layer
Connection Layer
OpenSSH Components
Internal Process Flow