SSH and Terminal Workflow¶
SSH is how students connect to remote Ubuntu servers for labs. This page covers key-based login, a simple SSH config file, and terminal habits that reduce mistakes.
1. Verify SSH Works¶
From your local computer:
If this works, exit the server:
2. Generate an SSH Key If Needed¶
On your local computer:
Accept the default file path unless your instructor tells you otherwise. Use a passphrase when possible.
3. Copy the Public Key to the Server¶
Preferred method:
If ssh-copy-id is not available, print your public key:
Then add it to this file on the server:
4. Create an SSH Config Entry¶
On your local computer, edit:
Add:
Connect with:
5. Terminal Habits for Labs¶
| Habit | Why it matters |
|---|---|
Run pwd before editing files | Confirms where you are. |
Run ls or tree before deleting files | Avoids accidental deletion. |
Use mkdir -p labs/week01 | Creates repeatable folder structure. |
| Keep one terminal for notes/output | Makes screenshots and submissions easier. |
| Copy exact error messages | Troubleshooting depends on exact text. |
6. Useful Commands¶
7. Classroom Checkpoint¶
Submit or record:
- A successful SSH login using your short host alias, such as
ssh course-server. -
Output of:
Troubleshooting¶
| Error | Likely Cause | Fix |
|---|---|---|
Permission denied (publickey) | Server does not have your public key | Re-run ssh-copy-id or check authorized_keys. |
Connection timed out | Firewall, wrong IP, server off | Verify IP, cloud firewall, and UFW rules. |
REMOTE HOST IDENTIFICATION HAS CHANGED | Server was rebuilt or IP reused | Confirm this is expected, then remove the old key from ~/.ssh/known_hosts. |
Next Step¶
Continue to Git and GitHub Setup.