Connecting with SSH
SSH (Secure SHell) lets you type commands on a computer that's somewhere else: in the next room, in a school server closet, or in a data center across the world. It's how almost every Linux server gets managed.
You will learn
- How SSH works: client, server, port 22, encryption
- How to switch on the SSH server on Rocky and on Ubuntu
- How to log in, what the “fingerprint” question means, and how to log out
- How to use SSH keys so you don't need a password
The big idea
Think of SSH as a secure phone call between two computers:
- Your computer is the client. It makes the call using the
sshcommand. - The remote computer is the server. It answers the call with a program called
sshd(the “SSH daemon”) that listens on port 22. - Everything you send is encrypted. Someone snooping on the Wi-Fi only sees scrambled nonsense, not your password.
Step 1: make sure the server is listening
Most servers have SSH turned on already. If you're setting up your own machine (for example, a spare laptop running Linux), this is where the families differ:
sudo dnf install openssh-server sudo systemctl enable --now sshd sudo firewall-cmd --list-services
The service is named sshd. The firewall is on by default and already allows ssh.
sudo apt update sudo apt install openssh-server systemctl status ssh
The service is named ssh (sshd also works). It starts automatically after you install it. The firewall (ufw) is off by default.
Then find the server's IP address, which is its number on the network:
hostname -I
(Linux Sysadmin, lesson 1 explains IP addresses, ip a and the old ifconfig properly.)
Step 2: connect from your computer
This part is the same everywhere: Windows PowerShell, Mac Terminal or Linux. (Prefer an app like PuTTY or iTerm2? That's lesson 4.)
The very first time, you'll see this question:
The authenticity of host '192.168.1.50 (192.168.1.50)' can't be established. ED25519 key fingerprint is SHA256:Zk3dQ1v8mX4pR2yLw9cT0aB7nE5fH6jK1uS3gV8qW2o. Are you sure you want to continue connecting (yes/no/[fingerprint])?
That's SSH saying “I've never talked to this server before. Is this really the one you meant?” It's like caller ID for computers. On your own network, type the whole word yes. SSH remembers the server from then on. If that fingerprint ever changes, SSH shows a big scary warning, because someone could be pretending to be your server. When that happens, stop and ask whoever runs the server.
Next, type your password. Nothing appears while you type, not even dots. That's on purpose, so nobody can count the letters. Type it and press Enter anyway.
When you're done, type exit to hang up and return to your own computer.
Try it
This terminal starts on your laptop (a pretend one). Somewhere on the network there's a server at 192.168.1.50. Username: student. Password: linux.
Level up: SSH keys
Passwords can be guessed. SSH keys are much safer, and they save you typing. A key comes as a pair:
- The public key (
id_ed25519.pub) is like a padlock. You can hand out copies to any server you want to log in to. - The private key (
id_ed25519) is the only key that opens those padlocks. It stays on your computer. Never share it, email it, or paste it anywhere, including into an AI chat.
# 1. make a key pair (press Enter to accept the defaults) ssh-keygen -t ed25519 # 2. put your padlock on the server (asks for your password one last time) ssh-copy-id student@192.168.1.50 # 3. log in, no password needed ssh student@192.168.1.50
On Windows, ssh-copy-id doesn't exist. Lesson 4 shows the one-line replacement, plus PuTTY, iTerm2 and phone apps. The bonus missions above let you practice all of this.
When it doesn't work
| Error | What it usually means |
|---|---|
Connection timed out | Wrong IP address, the server is off, or a firewall is blocking port 22. |
Connection refused | The computer is there, but the SSH server isn't running. Start it: sshd on Rocky, ssh on Ubuntu. |
Permission denied | Wrong username or password. Check the part before the @. |
Could not resolve hostname | A typo in the server name, or your computer doesn't know that name. Use the IP address instead. |
REMOTE HOST IDENTIFICATION HAS CHANGED | The server's fingerprint changed. Maybe it was reinstalled, maybe something shady is going on. Ask the admin before you continue. |
Only SSH into machines you own or have been given an account on. Trying to guess passwords on other people's servers is illegal, even “just to see.” Servers log every attempt: Rocky writes them to /var/log/secure and Ubuntu to /var/log/auth.log.
Quick check
1. You type your password and nothing shows up on screen. What should you do?
✓ Yes. Linux never shows password characters, not even as dots.
2. What's the SSH service called on Rocky vs Ubuntu?
✓ Correct. Ubuntu also accepts sshd as a nickname, but ssh is the real name there.
3. Which SSH key file is safe to copy to servers?
✓ The .pub (public) one is the padlock you can hand out. The private key never leaves your computer.