Sub topic 12
SSH: encrypted command-line access
This chapter assumes you can use a Windows command prompt or a Linux shell and know what an IP address, a port, and a firewall are.
What SSH is
Secure Shell (SSH) is a protocol that gives you an encrypted command-line session on another computer. It uses TCP port 22 by default. Everything you type and everything the host prints is encrypted in transit. SSH replaced Telnet, which sent text, including passwords, in the clear on TCP port 23.
On the A+ exam, SSH is the answer when a scenario needs remote command-line access to a Linux server, router, switch, or other network device.
Connecting
The basic form is ssh user@host. This opens a session as user admin on the host at 192.168.1.10:
ssh [email protected]Linux, macOS, and current versions of Windows include an SSH client. PuTTY is a common free client on older Windows systems.
If the server listens on a different port, add -p:
ssh -p 2222 [email protected]What happens at connection time
On your first connection, the client shows the server's host key fingerprint and asks whether to trust it. After you accept, the client saves the key in ~/.ssh/known_hosts. If the key changes later, the client warns you. That change can mean the server was rebuilt, or that someone is impersonating it.
Authentication methods
| Method | How it works | Notes |
|---|---|---|
| Password | You type the account password | Simple, but exposed to guessing attacks |
| Key pair | A private key stays on your machine and a public key is installed on the server | Stronger. Can be protected by a passphrase |
To set up key authentication:
ssh-keygen -t ed25519
ssh-copy-id [email protected]The first command creates the key pair. The second copies the public key to the server. Never share the private key.
Moving files
SSH also carries file transfers. scp copies files over an SSH connection, and SFTP provides an interactive file-transfer session over SSH.
scp report.txt [email protected]:/home/admin/Common problems
- Connection refused or timed out: the SSH service is not running, or a firewall blocks port 22.
- Permission denied: the username, password, or key is wrong.
- Host key warning: do not ignore it until you know why the key changed.
SSH compared with similar tools
SSH gives a text session only. RDP and VNC show a graphical desktop. Telnet is also text-only but unencrypted, so it is not acceptable for administration over untrusted networks.
Exercise
A technician must manage a Linux server from home over the internet. They need a command-line session where passwords cannot be read by someone capturing traffic. Which protocol and default port should they use, and what should they do to improve login security?
Show answer
Use SSH on TCP port 22. Improve login security by using key-based authentication instead of passwords, and by limiting who can reach the port, for example through a firewall rule or by connecting over a VPN.