Unit 7 of 8 · about 2 hours · implement

SSH trust, keys, forwarding and tmux sessions

Remote machines do the heavy work. Keys plus tmux turn a fragile connection into a durable session with no password typed twice.

You'll be able to

  • Create ed25519 keys, configure hosts, copy keys and disable password authentication.
  • Forward a remote port to localhost and run it in the background without secrets in logs.
  • Run a task in a named tmux session that survives disconnects and reattach cleanly.

Covers

SSH trust, keys, forwarding and durable tmux sessions
1

Read

In this order, only the parts listed

0 of 2 done

  1. Command-line environment: remote machinesThe Missing Semester of Your CS Education

    Remote Machines: ssh invocation, key generation with ssh-keygen -a 100 -t ed25519, ssh-copy-id, ~/.ssh/config entries and LocalForward; Exercises under Remote Machines (SSH)

  2. Command-line environment: terminal multiplexersThe Missing Semester of Your CS Education

    Terminal Multiplexers: tmux sessions, detaching and reattaching, windows and panes; Exercises under Terminal Multiplexers

2

Focus on

  • Host trust and user trust are different files: known_hosts authenticates the server, authorized_keys authenticates you. Read first-connection prompts instead of reflex-typing yes.
  • One key per client, passphrase protected, loaded in the agent. The private key never leaves the client; copy the .pub with ssh-copy-id.
  • LocalForward exposes a remote port locally, and -N -f backgrounds the tunnel. Never paste tokens or keys into commands that land in shell history or logs.
  • tmux owns the session, not the correctness. Name sessions, detach with the prefix plus d, reattach with tmux a -t. A host reboot or a killed tmux server still ends the session.
Common mistakes · 3
  • Agent forwarding to untrusted hosts. A root user on the remote can use your agent, so forward only where needed and prefer ProxyJump.
  • Leaving password authentication enabled. Keys plus disabled passwords close brute force; the exercises walk through sshd_config.
  • Treating tmux as supervision. It survives disconnects, not reboots or out-of-memory kills; real services need a supervisor.
3

Try it yourself

Closed-book, before checking anything

Generate ssh-keygen -a 100 -t ed25519 demokey and get demokey plus demokey.pub. Add a Host vm entry with HostName, User and IdentityFile, then verify with ssh -G vm that hostname, user, port and identityfile resolve (observed with OpenSSH 10.2). Then run tmux new -d -s atlas, tmux ls, detach, reattach and kill-session (observed with tmux 3.6a).
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.known_hosts versus authorized_keys: who trusts whom?Answer

    known_hosts on the client records server keys, so the client trusts the server. authorized_keys on the server records client keys, so the server trusts the client.

  2. 2.What does LocalForward 9999 localhost:8888 in Host vm do?Answer

    Connections to local port 9999 travel through the SSH link to vm and emerge as connections to its localhost:8888.

  3. 3.SSH drops mid-run inside tmux. What survives?Answer

    The tmux server and its processes keep running. Reattach to see the output intact. Anything outside tmux got SIGHUP unless started with nohup.

  4. 4.Why is ssh -N -f useful for forwarding, and what do the flags do?Answer

    -N runs no remote command and -f backgrounds after authentication: a quiet tunnel with no shell.

5

Practice

  • Missing Semester SSH exercise chain

    Exercises under Remote Machines (SSH), items 1 to 5 and 7: key pair, Host vm config, ssh-copy-id, a webserver on 8888 reached at localhost:9999, PasswordAuthentication off, and -N -f background forwarding

  • Missing Semester tmux tutorial exercise

    Exercises under Terminal Multiplexers: follow the linked tmux tutorial, then customize tmux.conf

You're done when

You reach the remote with no password prompt, the forwarded port serves locally, and a reattached session shows the task log intact after a disconnect.

Only when you can do this without notes.

Leads to

Notes

Resources · 1 for this unit, 6 more in the section
  • The Missing Semester of Your CS EducationMIT · primary

    Complete the 2026 lectures on the shell, command-line environment, development tools, debugging and profiling, Git, packaging and shipping code, and code quality. Apply every exercise to the same stage project.

Also in this section

  • pytest documentationpytest · required

    Use Get Started, fixtures, parametrization, monkeypatch, caplog and temporary paths to build behavior and failure-path tests without order dependence.

  • Hypothesis documentationHypothesis · required

    Follow the Quick start and property-based testing guides, then generate operation histories and retain the minimized example for one real defect.

  • The Art of DebuggingStas Bekman · support

    Use the Unix, Python and compiled-code sections during a real seeded defect. Follow the evidence and tiny-reproducer workflow rather than reading the unfinished book front to back.

  • Pro GitGit project · support

    Use Chapters 2-3 and the sections on debugging, internals and recovery while constructing a history for bisect and recovering a deliberately displaced commit.

  • Stas' Python Cookbook - debugging and testingStas Bekman · support

    Use Part III and the packaging sections for debugger, traceback, pytest, logging, profiling and clean-environment recipes.

  • AlgoMaster Python - mockingAlgoMaster · support

    Use the Mocking lesson for unittest.mock: Mock versus MagicMock, patch targets, autospec and the over-mocking trap. The pytest docs remain the reference for fixtures and monkeypatch.