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
ed25519keys, 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
Read
In this order, only the parts listed
0 of 2 done
- 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/configentries andLocalForward; Exercises under Remote Machines (SSH) - 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
Focus on
- Host trust and user trust are different files:
known_hostsauthenticates the server,authorized_keysauthenticates 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
.pubwithssh-copy-id. LocalForwardexposes a remote port locally, and-N -fbackgrounds 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.
Try it yourself
Closed-book, before checking anything
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).Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.
known_hostsversusauthorized_keys: who trusts whom?Answerknown_hostson the client records server keys, so the client trusts the server.authorized_keyson the server records client keys, so the server trusts the client.2.What does
LocalForward 9999 localhost:8888inHost vmdo?AnswerConnections to local port 9999 travel through the SSH link to
vmand emerge as connections to itslocalhost:8888.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
SIGHUPunless started withnohup.4.Why is
ssh -N -fuseful for forwarding, and what do the flags do?Answer-Nruns no remote command and-fbackgrounds after authentication: a quiet tunnel with no shell.
Practice
- Missing Semester SSH exercise chain
Exercises under Remote Machines (SSH), items 1 to 5 and 7: key pair,
Host vmconfig,ssh-copy-id, a webserver on 8888 reached atlocalhost:9999,PasswordAuthentication off, and-N -fbackground 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:MockversusMagicMock,patchtargets,autospecand the over-mocking trap. The pytest docs remain the reference for fixtures andmonkeypatch.