Linux Mastery
The Human Knowledge Project
Chapter 18 — SSH & Remote Systems
Why This Chapter Matters
One of Linux's greatest strengths is remote administration.
Linux systems can be managed from:
- another room
- another building
- another city
- another country
- another continent
Administrators routinely maintain systems without physically touching them.
This is possible because Linux was designed from the beginning as a multi-user, networked operating system.
The primary technology that makes secure remote administration possible is:
SSH
Understanding SSH is an essential step toward becoming an effective Linux user or administrator.
Learning Objectives
Upon completing this chapter, you will be able to:
- explain what SSH is
- distinguish between an SSH client and SSH server
- connect to a remote Linux system
- identify the purpose of the
sshdservice - start and enable the SSH server
- explain how SSH encrypts communications
- understand why SSH is fundamental to Linux administration
Introduction
Imagine sitting at your computer in Washington while managing a Linux server in New York.
Or administering a cloud server located on another continent.
To Linux, distance makes very little difference.
Once a secure connection has been established, the remote computer behaves almost as though you were sitting directly in front of it.
This ability has made Linux the operating system of choice for servers, cloud infrastructure, research laboratories, universities, and businesses around the world.
1. What Is SSH?
SSH stands for:
Secure Shell
SSH creates an encrypted connection between two computers.
It allows users to:
- log into remote systems
- execute commands
- transfer files
- administer servers
- automate system management
SSH has become the standard method for securely managing Linux systems across networks.
THKI Memory Aid
Your Computer │ Encrypted Connection │ Remote Linux System
SSH creates a secure communication channel between two computers.
2. Why SSH Matters
Before SSH became common, older remote-access protocols often transmitted passwords in plain text.
Anyone monitoring the network could potentially read those passwords.
SSH solves this problem by encrypting the entire communication session.
Encryption protects:
- usernames
- passwords
- commands
- file transfers
- administrative activity
Today, SSH is one of the most important security technologies used by Linux administrators.
3. SSH Client and SSH Server
SSH consists of two cooperating components.
| Component | Purpose |
|-----------|---------|
| SSH Client | Initiates connections to remote systems |
| SSH Server (sshd) | Accepts incoming SSH connections |
The client starts the conversation.
The server listens for connection requests.
Both are required for successful remote administration.
4. The sshd Service
The SSH server process is usually named:
sshd
which stands for:
SSH daemon
The SSH daemon runs quietly in the background waiting for connection requests.
Without sshd, a Linux computer cannot accept incoming SSH connections.
Servers commonly leave sshd running continuously.
5. Checking the SSH Service
To determine whether the SSH service is running:
systemctl status ssh
On some Linux distributions the service is named:
systemctl status sshd
The output indicates whether the service is:
- active
- inactive
- enabled
- disabled
Checking service status is often the first troubleshooting step when SSH connections fail.
6. Starting the SSH Server
To start the SSH service immediately:
sudo systemctl start ssh
This launches the SSH daemon and allows remote systems to connect.
If the service is stopped again or the computer is rebooted, SSH will no longer accept connections unless it is configured to start automatically.
7. Starting SSH Automatically
To enable SSH each time Linux boots:
sudo systemctl enable ssh
This tells systemd to start the SSH service automatically during future system startups.
Remember:
- start runs the service now.
- enable starts the service automatically after every boot.
THKI Memory Aid
start ↓ Run Now enable ↓ Run Every Boot
8. Connecting to a Remote System
The basic SSH command is:
ssh username@hostname
Example:
ssh norm@192.168.1.50
After authentication, a secure shell opens on the remote computer.
Commands entered after the connection is established execute on the remote system rather than on the local computer.
9. What Happens During Login?
A typical SSH connection follows these steps:
- Connect to the remote host.
- Negotiate encryption.
- Authenticate the user.
- Launch the user's shell.
- Begin the remote session.
From this point forward, nearly everything typed into the terminal runs on the remote Linux system.
This makes SSH feel almost like sitting in front of the remote computer.
10. Remote Shell Prompt
After logging in, the command prompt usually changes.
Example:
norm@SERVER:~$
This reminds you that commands are now running on the remote machine.
When administering multiple systems, always pay attention to the prompt to avoid making changes on the wrong computer.
11. Ending an SSH Session
When you finish working on the remote system, disconnect using:
exit
or press:
Ctrl + D
The remote shell closes, and you return to the command prompt on your local computer.
12. Hostnames and IP Addresses
SSH can connect using either:
- a hostname
- a DNS name
- an IP address
Examples:
ssh user@example.com
ssh user@192.168.1.20
Using hostnames is usually easier to remember, while IP addresses are useful for troubleshooting or when DNS is unavailable.
13. SSH Port 22
By default, SSH communicates using:
Port 22
Firewalls and routers must allow access to this port before remote SSH connections can be established.
Many administrators leave SSH on Port 22, while others choose a different port to reduce automated scanning attempts.
14. SSH Keys
Although SSH supports password authentication, many Linux administrators prefer using SSH keys.
SSH keys provide:
- stronger security
- passwordless login
- automation support
- protection against many password-based attacks
Large organizations often require SSH keys instead of passwords for administrative access.
15. Generating an SSH Key Pair
To create a new SSH key pair:
ssh-keygen
The program asks several questions, including where to store the keys and whether to protect the private key with a passphrase.
Pressing Enter accepts the default values.
16. Public and Private Keys
SSH key generation creates two related files.
| File | Purpose |
|------|---------|
| id_ed25519 (or id_rsa) | Private key |
| id_ed25519.pub (or id_rsa.pub) | Public key |
Modern Linux systems usually recommend the Ed25519 key type.
Older systems may still use RSA keys.
THKI Memory Aid
Private Key ↓ Keep Secret Public Key ↓ Share Freely
Your private key should never be shared with anyone.
Your public key is intended to be copied to remote systems.
17. Why SSH Keys Matter
When using SSH keys, the remote computer verifies that your private key matches the public key it already trusts.
Because your private key never leaves your computer, authentication is both convenient and highly secure.
SSH keys also make automation possible because scripts can authenticate without repeatedly prompting for passwords.
THKI Insight
Many organizations disable password authentication entirely and require SSH keys for administrative access.
Keys are generally more secure and easier to automate than passwords.
18. Installing Your Public Key
To copy your public key to a remote Linux system:
ssh-copy-id user@remotehost
This installs your public key into the remote account.
Future SSH logins can then authenticate using your key pair instead of a password.
19. Known Hosts
The first time you connect to a remote system, SSH asks whether you trust that computer.
If you answer yes, SSH records information about the remote system in:
~/.ssh/known_hosts
During future connections, SSH compares the stored information with the remote host.
If something changes unexpectedly, SSH displays a warning.
This helps protect against impersonation attacks.
20. SSH Configuration Files
SSH behavior can be customized using configuration files.
Common files include:
| File | Purpose |
|------|---------|
| /etc/ssh/sshd_config | SSH server configuration |
| ~/.ssh/config | User SSH client configuration |
To examine the server configuration:
less /etc/ssh/sshd_config
After changing the server configuration, restart the SSH service:
sudo systemctl restart ssh
21. scp — Secure Copy
SSH can also transfer files securely.
The command used is:
scp
Copy a local file to a remote system:
scp file.txt user@remotehost:/home/user/
Copy a remote file back to your current directory:
scp user@remotehost:/home/user/file.txt .
The period (.) represents the current directory.
22. Copying Entire Directories
To copy an entire directory recursively:
scp -r project/ user@remotehost:/backup/
The -r option tells scp to copy all files and subdirectories.
THKI Memory Aid
Local Computer │ scp │ Remote Computer
Remember:
sshruns commands remotely.scpcopies files.- Both use the same encrypted SSH connection.
23. rsync Over SSH
The rsync command can synchronize files through an SSH connection.
Example:
rsync -av project/ user@remotehost:/backup/project/
Unlike ordinary copying, rsync transfers only files that have changed.
Benefits include:
- faster synchronization
- reduced bandwidth usage
- efficient backups
- incremental transfers
This makes rsync one of the most valuable tools for remote system administration.
24. Persistent Terminal Sessions
Long-running administrative work sometimes continues for hours.
If the network connection is interrupted, ordinary SSH sessions end immediately.
Linux provides tools that allow terminal sessions to continue running even after an SSH connection is lost.
Two of the most common are:
tmuxscreen
25. tmux
tmux stands for:
Terminal Multiplexer
Start a new session:
tmux
Detach from the session without stopping it:
Press:
Ctrl + B
then:
D
Reattach later:
tmux attach
Detached sessions continue running even after the SSH connection closes.
THKI Insight
Many experienced Linux administrators begin every SSH session by starting
tmux.If their network connection drops, their programs continue running on the remote system, allowing them to reconnect later without losing work.
26. screen
Another terminal multiplexer is:
screen
Start a session:
screen
Detach:
Ctrl + A
then:
D
Reconnect later:
screen -r
Although screen is older than tmux, both remain useful for remote administration.
27. tmux vs. screen
| Tool | Notes |
|------|-------|
| tmux | Modern, highly configurable, widely preferred |
| screen | Older, simpler, still widely available |
Both tools help preserve long-running remote sessions and reduce the risk of losing work due to network interruptions.
28. Real-World Remote Administration
Remote administration has transformed the way Linux systems are managed.
A single administrator can securely maintain hundreds—or even thousands—of computers located around the world.
Typical daily tasks include:
- logging into remote servers
- installing software
- updating systems
- restarting services
- monitoring logs
- transferring files
- synchronizing backups
Most of this work happens without anyone physically touching the remote machine.
29. A Typical Administrative Workflow
A Linux administrator might perform the following steps:
Connect to the remote server:
ssh admin@server
Start a persistent session:
tmux
Monitor system logs:
tail -f /var/log/syslog
Restart a service if needed:
sudo systemctl restart ssh
Transfer updated configuration files:
scp config.conf admin@server:/etc/
Synchronize project files:
rsync -av project/ admin@server:/srv/project/
Detach from the tmux session before disconnecting.
The administrator can later reconnect and continue working exactly where they left off.
30. Why Remote Administration Matters
Without remote administration:
- cloud computing would be impractical
- web hosting would require constant physical access
- large server farms would need enormous on-site staff
- worldwide infrastructure would be much more expensive to operate
SSH is one of the technologies that makes modern computing possible.
31. SSH Security Best Practices
Because SSH often provides administrative access, protecting it is extremely important.
Good security practices include:
- using strong passwords
- preferring SSH keys over passwords
- keeping software updated
- limiting administrative access
- protecting SSH with a firewall
- disabling unused accounts
- reviewing authentication logs
Following these practices greatly reduces the risk of unauthorized access.
32. Why Root Login Is Usually Disabled
Many Linux administrators disable direct remote login as the:
root
user.
Instead, they log in using a normal account and perform administrative tasks with:
sudo
This approach:
- reduces accidental mistakes
- improves accountability
- limits opportunities for attackers
- provides better auditing
It also reinforces the Linux principle of least privilege.
THKI Insight
Good administrators spend most of their time as ordinary users.
They use
sudoonly when administrative privileges are actually required.
33. Safety Note
SSH is a powerful administrative tool.
Incorrect configuration can:
- prevent remote access
- lock administrators out of systems
- expose servers to security risks
- interrupt automated tasks
Always test configuration changes carefully before deploying them to production systems.
When possible, keep an existing SSH session open while testing changes so you can recover if something goes wrong.
Chapter Summary
| Command / Concept | Purpose |
|-------------------|---------|
| ssh | Secure remote login |
| sshd | SSH server daemon |
| ssh-keygen | Generate SSH key pairs |
| ssh-copy-id | Install a public key on a remote system |
| scp | Securely copy files |
| rsync | Efficient file synchronization |
| tmux | Persistent terminal sessions |
| screen | Terminal multiplexer |
Key Ideas
SSH is the standard method for securely administering Linux systems across networks.
Understanding:
- secure remote login
- SSH keys
- encrypted communication
- secure file transfer
- persistent terminal sessions
provides the foundation for modern Linux system administration.
Whether managing a home server or a global cloud infrastructure, SSH is one of the most valuable tools in the Linux administrator's toolkit.
Practice Exercises
- Determine whether SSH is installed on your system.
- Check the SSH service status.
- Start the SSH service (if permitted).
- Enable SSH to start automatically during boot.
- Verify that SSH is listening on Port 22.
- Connect to another Linux system using SSH, if available.
- Connect to your own computer using:
ssh localhost
if the SSH server is running.
- Generate an SSH key pair using:
- Locate your public and private key files.
- Explain the difference between the public key and the private key.
- Install a public key on another Linux system using:
- Copy a file using:
- Copy an entire directory using:
- Synchronize two directories using:
- Start a
tmuxsession. - Detach and reattach to the session.
- Repeat the exercise using
screen, if installed. - Explain why persistent sessions are valuable during remote administration.
- Describe a real-world situation where SSH would be essential.
- Explain why SSH keys are generally preferred over passwords.
- Explain why direct root login is often disabled.
- Describe a workflow involving:
ssh-keygen
ssh-copy-id
scp
scp -r
rsync -av
- SSH
scprsynctmux
- Explain how SSH demonstrates the Linux philosophy of small tools working together.
Looking Ahead
You now understand how Linux systems can be administered securely from almost anywhere in the world.
In the next chapter, you'll learn how Linux automates repetitive work using scheduled tasks, allowing maintenance jobs, backups, and other routine operations to run automatically—even when no one is logged in.