Installing SSH
Topics
Level: Beginner → Intermediate
Before learning authentication, keys, or tunneling, you must know how to properly install, verify, manage, and troubleshoot SSH on different operating systems.
Table of Contents
- What is OpenSSH?
- SSH Client vs SSH Server
- OpenSSH Components
- Linux Installation
- Ubuntu/Debian Installation
- RHEL/CentOS/Rocky/AlmaLinux Installation
- Arch Linux Installation
- Windows Installation
- macOS Installation
- Systemd Services
- SSH Configuration Files
- Verification and Testing
- Internal Working After Installation
- Architecture Diagram
- Commands
- Code Examples
- Real-World Examples
- Production Examples
- Common Mistakes
- Troubleshooting
- Security Notes
- Interview Questions
- Hands-On Labs
- Exercises
- Quiz
1. What is OpenSSH?
OpenSSH is the most widely used implementation of SSH.
Project:
OpenSSH
Provides:
SSH Client
SSH Server
SFTP
SCP
Key Management
Port Forwarding
Secure Remote Access
Why OpenSSH?
Benefits:
Open Source
Secure
Cross Platform
Industry Standard
Actively Maintained
OpenSSH in Modern Systems
Used in:
Linux Servers
AWS EC2
Azure VMs
Google Cloud
Docker Hosts
Kubernetes Nodes
Enterprise Data Centers
2. SSH Client vs SSH Server
Many beginners confuse these.
SSH Client
Used to initiate connections.
Command:
ssh
Example:
ssh user@server
Installed on:
Your Laptop
Your Workstation
Admin Computer
SSH Server
Accepts incoming connections.
Process:
sshd
Installed on:
Linux Server
Cloud VM
Remote Machine
Diagram
+-------------+
| SSH Client |
+-------------+
|
|
Encrypted Connection
|
|
+-------------+
| SSH Server |
| sshd |
+-------------+
Simple Rule
Client = Connects
Server = Accepts Connections
3. OpenSSH Components
OpenSSH installs multiple tools.
ssh
Client program.
Example:
ssh user@server
sshd
Server daemon.
Example:
sudo systemctl status ssh
ssh-keygen
Generates keys.
Example:
ssh-keygen
ssh-agent
Stores private keys in memory.
Example:
ssh-agent
ssh-add
Loads keys into agent.
Example:
ssh-add ~/.ssh/id_ed25519
scp
Secure file copy.
Example:
scp file.txt server:/tmp
sftp
Secure file transfer.
Example:
sftp user@server
Component Overview
| Component | Purpose |
|---|---|
| ssh | Client |
| sshd | Server |
| ssh-keygen | Key generation |
| ssh-agent | Key storage |
| ssh-add | Add keys |
| scp | Secure copy |
| sftp | Secure transfer |
4. Linux Installation
Most Linux distributions use OpenSSH.
Two packages:
openssh-client
openssh-server
Client Package
Provides:
ssh
scp
sftp
ssh-keygen
Server Package
Provides:
sshd
Verify Existing Installation
Check client:
ssh -V
Example:
OpenSSH_9.8
Check server:
which sshd
5. Ubuntu / Debian Installation
Update package list:
sudo apt update
Install client:
sudo apt install openssh-client
Install server:
sudo apt install openssh-server
Verify installation:
ssh -V
Check service:
sudo systemctl status ssh
Enable service:
sudo systemctl enable ssh
Start service:
sudo systemctl start ssh
Verify Listening Port
ss -tlnp | grep ssh
Expected:
LISTEN 0 128 *:22
6. RHEL / CentOS / Rocky / AlmaLinux
Install package:
sudo dnf install openssh-server
or
sudo yum install openssh-server
Enable service:
sudo systemctl enable sshd
Start service:
sudo systemctl start sshd
Check status:
sudo systemctl status sshd
Verify Port
ss -tlnp | grep sshd
7. Arch Linux Installation
Install package:
sudo pacman -S openssh
Enable service:
sudo systemctl enable sshd
Start service:
sudo systemctl start sshd
Verify:
systemctl status sshd
8. Windows Installation
Modern Windows includes OpenSSH.
Check Existing Installation
PowerShell:
ssh -V
Example:
OpenSSH_for_Windows
Install via Settings
Navigate:
Settings
→ Apps
→ Optional Features
→ Add Feature
→ OpenSSH Client
Install Server:
OpenSSH Server
PowerShell Installation
Check capability:
Get-WindowsCapability -Online | Findstr OpenSSH
Install Client:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Install Server:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start Service
Start-Service sshd
Enable Auto Start
Set-Service -Name sshd -StartupType Automatic
Verify
Get-Service sshd
9. macOS Installation
OpenSSH is preinstalled.
Check version:
ssh -V
Example:
OpenSSH_9.x
Verify client:
which ssh
Example:
/usr/bin/ssh
Enable Remote Login
Navigate:
System Settings
→ General
→ Sharing
→ Remote Login
Or command line:
sudo systemsetup -setremotelogin on
Verify:
sudo systemsetup -getremotelogin
10. Systemd Services
Linux uses:
systemd
to manage SSH service.
Common Commands
Status:
sudo systemctl status ssh
or
sudo systemctl status sshd
Start:
sudo systemctl start ssh
Stop:
sudo systemctl stop ssh
Restart:
sudo systemctl restart ssh
Reload:
sudo systemctl reload ssh
Enable at Boot:
sudo systemctl enable ssh
Disable:
sudo systemctl disable ssh
Service Lifecycle Diagram
Installed
|
Enable
|
Boot
|
Start
|
Running
|
Restart
|
Stop
11. SSH Configuration Files
Understanding configuration files is critical.
Client Configuration
Location:
~/.ssh/config
Example
Host prod
HostName 10.0.0.5
User ubuntu
Global Client Config
Location:
/etc/ssh/ssh_config
Server Configuration
Location:
/etc/ssh/sshd_config
Example
Port 22
PermitRootLogin no
PasswordAuthentication yes
PubkeyAuthentication yes
Host Keys
Directory:
/etc/ssh/
Files:
ssh_host_rsa_key
ssh_host_ed25519_key
ssh_host_ecdsa_key
User Keys
Directory:
~/.ssh/
Examples:
id_ed25519
id_ed25519.pub
authorized_keys
known_hosts
Configuration Layout
/etc/ssh/
│
├── ssh_config
├── sshd_config
├── ssh_host_rsa_key
├── ssh_host_ed25519_key
└── ssh_host_ecdsa_key
12. Verification and Testing
Verify Client
ssh -V
Verify Server
which sshd
Verify Service
sudo systemctl status ssh
Verify Listening Port
ss -tlnp | grep ssh
Test Local Connection
ssh localhost
Expected:
Successful Login
Verify Process
ps aux | grep sshd
Verify Firewall
sudo ufw status
Verify Remote Connectivity
ssh user@server-ip
13. Internal Working After Installation
When SSH starts:
Step 1
OS launches:
sshd
Step 2
sshd loads:
Host Keys
Configuration
Authentication Rules
Step 3
sshd listens on:
Port 22
Step 4
Client connects.
Step 5
Secure tunnel created.
Step 6
Authentication occurs.
Step 7
Session established.
Internal Diagram
OS
|
sshd
|
Port 22 Listening
|
Client Connects
|
Encryption
|
Authentication
|
Shell Session
14. Architecture Diagram
+----------------------+
| SSH Client |
| ssh |
+----------------------+
|
|
Encrypted Channel
|
|
+----------------------+
| SSH Server |
| sshd |
+----------------------+
|
|
Configuration Files
|
|
+----------------------+
| /etc/ssh/sshd_config |
+----------------------+
15. Commands
Check version:
ssh -V
Generate key:
ssh-keygen
Check daemon:
ps aux | grep sshd
Check service:
systemctl status ssh
Check ports:
ss -tlnp
Test localhost:
ssh localhost
16. Code Examples
Install Ubuntu:
sudo apt update
sudo apt install openssh-server openssh-client
Enable service:
sudo systemctl enable ssh
sudo systemctl start ssh
Verify:
ssh localhost
17. Real-World Examples
Developer Laptop:
SSH Client Installed
Production Server:
OpenSSH Server Installed
Workflow:
ssh dev@server
18. Production Examples
AWS EC2
Laptop
|
SSH Client
|
Internet
|
EC2 Instance
|
sshd
Enterprise Data Center
Admin Workstation
|
SSH
|
1000+ Linux Servers
19. Common Mistakes
Mistake 1
Installing only client.
Cannot accept incoming connections.
Mistake 2
Forgetting to start sshd.
Mistake 3
Firewall blocks port 22.
Mistake 4
Editing config without restart.
Mistake 5
Wrong service name.
Ubuntu:
ssh
RHEL:
sshd
20. Troubleshooting
ssh Command Missing
Check:
which ssh
Install client package.
sshd Missing
Check:
which sshd
Install server package.
Connection Refused
Check:
systemctl status ssh
Port Closed
Check:
ss -tlnp
Firewall Issue
Check:
ufw status
Configuration Error
Validate:
sudo sshd -t
No output means valid.
21. Security Notes
Install only required components.
Keep OpenSSH updated.
Verify:
sudo sshd -t
before restarting.
Use:
Public Key Authentication
instead of passwords.
Disable root login when possible.
22. Interview Questions
Q1
Difference between SSH Client and SSH Server?
Answer:
Client initiates connection.
Server accepts connection.
Q2
What process provides SSH service?
Answer:
sshd
Q3
Where is sshd configuration stored?
Answer:
/etc/ssh/sshd_config
Q4
How do you verify OpenSSH installation?
Answer:
ssh -V
Q5
How do you test SSH locally?
Answer:
ssh localhost
23. Hands-On Labs
Lab 1
Verify SSH Client
ssh -V
Lab 2
Install OpenSSH Server
Ubuntu:
sudo apt install openssh-server
Lab 3
Start Service
sudo systemctl start ssh
Lab 4
Verify Listening Port
ss -tlnp | grep ssh
Lab 5
Connect to Local Machine
ssh localhost
Lab 6
Inspect Configuration
cat /etc/ssh/sshd_config
24. Exercises
Exercise 1
Explain the difference between
openssh-client and openssh-server.
Exercise 2
Draw SSH installation architecture.
Exercise 3
List important OpenSSH tools.
Exercise 4
Identify all SSH configuration files.
Exercise 5
Describe service startup flow.
25. Quiz
Question 1
OpenSSH Server process?
A. ssh
B. sshd
C. ssh-agent
D. scp
Answer:
B
Question 2
SSH server configuration file?
A. ssh.conf
B. ssh.cfg
C. sshd_config
D. sshd.conf
Answer:
C
Question 3
Command to verify SSH version?
A. sshd -v
B. ssh version
C. ssh -V
D. ssh --check
Answer:
C
Question 4
Which package accepts incoming SSH connections?
A. openssh-client
B. openssh-server
C. ssh-agent
D. scp
Answer:
B
Question 5
Command to validate sshd configuration?
sudo sshd -t
Answer:
Correct
Summary
You should now understand:
✓ OpenSSH
✓ Client vs Server Packages
✓ Linux Installation
✓ Windows Installation
✓ macOS Installation
✓ Systemd Services
✓ SSH Configuration Files
✓ Host Keys
✓ User Keys
✓ Verification and Testing
✓ Service Management
✓ Troubleshooting Installation Problems
Next Topic:
Topic #4 — SSH Connection Lifecycle
DNS Resolution
TCP Handshake
Protocol Version Exchange
Algorithm Negotiation
Host Verification
Key Exchange
Encryption Setup
Authentication
Session Creation
Channel Creation
Interactive Shell