Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A secure telephone line to another computer
SSH lets you type commands on a computer that is far away, as if you were sitting at it, through a line nobody can listen in on. Instead of a password you usually use a key pair: a public key you can give to any computer you want to log into, and a private key that never leaves your laptop. The remote computer checks you hold the private key without ever seeing it. When copying files back and forth, a clever tool called rsync only sends the parts that changed.
Supercomputer jobs, cloud GPU training, a rover’s onboard computer during field tests and a ground-station server all sit behind SSH. Mission and research data move with rsync and scp. Knowing the config file, jump hosts and port forwarding turns a fragile chain of manual logins into one command.
- 1. Which key may you give away?
- 2. rsync is fast at updating a copy because it…
- 3. In the demo, why does inserting text at the start not force a full resend with rsync?
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Keys and first connection
ssh-keygen -t ed25519 -C "me@laptop" # creates ~/.ssh/id_ed25519 (private) and .pub (public)
ssh-copy-id astro42@login1.hpc.example.edu # appends the public key to the server's ~/.ssh/authorized_keys
ssh astro42@login1.hpc.example.edu # log in; first time: verify the host key fingerprint!
ssh-add ~/.ssh/id_ed25519 # unlock once per session with ssh-agentProtect the private key with a passphrase and keep permissions strict (chmod 600, directory 700; ssh refuses keys that others can read). On first connection ssh shows the server’s key fingerprint; compare it with the one your administrator publishes, because accepting it blindly is how a man-in-the-middle gets in. Accepted keys are stored in ~/.ssh/known_hosts; a later mismatch produces the loud “REMOTE HOST IDENTIFICATION HAS CHANGED” warning.
Moving files
scp file host:dir/ (simple copy), sftp host (interactive), rsync -avz --progress src/ host:dst/ (incremental; the trailing slash on src/ means “contents of”). rsync --dry-run before --delete.
- 1. Where on the server does your public key go?
- 2. The first-connection fingerprint prompt protects you from…
- 3. Which tool resumes and updates large transfers efficiently?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.~/.ssh/config
Host cluster login*.hpc.example.edu
HostName login1.hpc.example.edu
User astro42
IdentityFile ~/.ssh/id_ed25519_hpc
Host gpu?? !gpu99
HostName %h.internal.hpc.example.edu
ProxyJump cluster # hop through the login node
LocalForward 8888 localhost:8888 # Jupyter on the compute node -> your laptop
Host *
ServerAliveInterval 60
IdentityFile ~/.ssh/id_ed25519Rules: blocks are read top to bottom; for each option, the first value obtained wins; Host patterns use * and ?, and !pattern excludes. So put specific hosts first and Host * last. ssh -G host prints the resolved configuration.
Tunnels
- Local forward
-L 8888:localhost:8888: connections to port 8888 on your laptop go through SSH to port 8888 on the remote side (Jupyter, TensorBoard, a robot’s web UI). - Remote forward
-R 9000:localhost:9000: the reverse direction. - Dynamic
-D 1080: a SOCKS proxy. - ProxyJump
-J bastion: reach internal machines through a gateway without storing keys on it (prefer it over agent forwarding, which lets the gateway’s admins use your agent).
- 1. Host * is the first block in a config and sets User a; a later Host box block sets User b. Connecting to box uses…
- 2. ssh -L 6006:localhost:6006 gpu07 lets you…
- 3. ssh -G host prints…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Remote development that survives
- tmux (or screen) keeps your shell, training runs and editors alive when the connection drops:
tmux new -s train, detach with Ctrl-b d,tmux attach -t train. - Remote IDEs: VS Code Remote-SSH and JetBrains Gateway run the language server on the remote machine and only the UI locally; Jupyter through a port forward.
- Flaky links:
ServerAliveInterval, connection multiplexing (ControlMaster auto,ControlPersist 10m) for many quick commands, mosh for roaming and high-latency connections. - Clusters: don’t compute on login nodes; request compute nodes from the scheduler (C5) and attach to them with ProxyJump.
Security essentials
Disable password authentication on servers you run, use keys with passphrases (or hardware keys: -t ed25519-sk), restrict authorized_keys entries (from=, command=), never copy private keys to shared machines, and verify host keys out of band (or with SSH certificates signed by a CA, which large sites use to avoid trust-on-first-use).
How rsync saves bandwidth
The receiver splits its old file into blocks of L bytes and sends a weak 32-bit rolling checksum and a strong hash of each. The sender slides a window over the new file: the weak checksum can be updated in O(1) per byte, a weak hit is confirmed with the strong hash, and matches become “copy block k” instructions. Data that merely moved (because of an insertion or deletion) is still found. Cost ≈ (N/L)·(checksum bytes) + (changes)·L, minimized near L ≈ √(checksum bytes · N / changes).
- 1. Your 3-day training run must survive a laptop going to sleep. Use…
- 2. rsync's weak checksum must be…
- 3. Agent forwarding to a shared server risks…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.SSH and rsync, measured
Exercise 1. For the configuration above, cluster resolves to login1 with user astro42 and the HPC key (the earlier block wins over Host *) while still picking up ServerAliveInterval 60 from Host *; gpu07 becomes ssh -i ~/.ssh/id_ed25519 -J cluster -L 8888:localhost:8888 astro42@gpu07.internal.hpc.example.edu; gpu99 is excluded by !gpu99; rover gets -p 2222 and user ubuntu. Hashed known_hosts entries are found by recomputing HMAC-SHA1 with each entry’s salt (and [host]:port for non-standard ports). An ed25519 key blob is 51 bytes and its SHA256 fingerprint is 43 base64 characters.
Exercise 2: the rsync algorithm. A 144 000-byte telemetry CSV, block size 1024, 20 bytes of checksums per block, 5 bytes per instruction:
| Edit | full copy | aligned blocks | rsync |
|---|---|---|---|
| change 10 bytes in the middle | 144 000 | 3 985 | 5 189 |
| insert 100 bytes at the start | 144 100 | 147 345 | 4 270 |
| append 2 KB | 146 048 | 6 043 | 6 213 |
| 5 scattered 1-byte changes | 144 000 | 8 081 | 9 285 |
Without a sliding search, an insertion makes every following block differ and the “diff” costs more than the file; rsync sends 34× less than a full copy. Where nothing shifts, aligned comparison is slightly cheaper (16 instead of 20 checksum bytes per block). Block-size sweep for the 5-change edit: 56 570 B at L = 64, 9 738 at 512, 9 285 at 1024, 12 655 at 2048, 46 146 at 8192, matching the predicted optimum √(20·144000/5) ≈ 759 within the factor-of-two grid. (Real rsync also run-length-codes consecutive copies and compresses literals.)
SSH in AI, robotics and aerospace
- HPC and cloud: login through bastions with ProxyJump, Jupyter and TensorBoard through local forwards, datasets synchronized with rsync.
- Robots in the field: SSH over Wi-Fi or a tether to onboard computers; tmux keeps ROS nodes running when the link drops.
- Ground stations: automated, key-restricted rsync jobs pull telemetry from antenna sites; checksums verify integrity.
- Fleets: SSH certificates from a CA instead of per-machine known_hosts management.
References
- T. Ylonen, C. Lonvick (2006). The Secure Shell (SSH) Protocol Architecture, RFC 4251; Transport Layer Protocol, RFC 4253.
- OpenSSH manual pages: ssh(1), ssh_config(5), sshd(8), ssh-keygen(1) (man.openbsd.org).
- A. Tridgell, P. Mackerras (1996). “The rsync algorithm.” Technical Report TR-CS-96-05, Australian National University.
- A. Tridgell (1999). Efficient Algorithms for Sorting and Synchronization. PhD thesis, Australian National University.
- D. J. Barrett, R. E. Silverman, R. G. Byrnes (2005). SSH, The Secure Shell: The Definitive Guide, 2nd ed. O’Reilly.