Loading
0x160Lesson 23 of 28

Work on remote machines

Connect with SSH keys, copy files, and keep work running with tmux.

24 min 5-question quiz
By the end of this lesson you can
  • Explain how SSH key authentication works
  • Connect and copy files with ssh, scp and rsync
  • Keep a session alive through a disconnect with tmux

Most servers have no screen. You reach them with SSH, which gives you an encrypted shell on a machine anywhere in the world: ssh crew@relay.kestrel.example. Once you’re in, everything in this track works the same. What changes is how you get in, and what happens if your connection drops.

Keys beat passwords

Generate a key pair once with ssh-keygen -t ed25519. The private key stays on your machine, and you should never share it. The public key goes on each server, in ~/.ssh/authorized_keys, and ssh-copy-id will put it there for you. When you connect, you prove you hold the private key without ever sending it.

Try it

Up to 15 XP

What happens when you connect

Step through a key-based login, and predict each stage.

Message 1 of 5Predicted 0/0
Your laptop
Server

Moving files

  • scp report.txt crew@relay:/tmp/ copies a file. It’s quick for a one-off.
  • rsync -av logs/ crew@relay:backup/logs/ copies only what changed, and can resume. It’s the better choice for folders and repeated copies. Mind the trailing slash: logs/ means “the contents of logs”.

Put your hosts in ~/.ssh/config and you can type ssh relay instead of the full address:

1Host relay
2    HostName relay.kestrel.example
3    User crew
4    IdentityFile ~/.ssh/id_ed25519

tmux: survive a dropped connection

If your connection drops, everything running in that shell usually dies with it. tmux keeps your session running on the server, so you can come back to it:

CommandWhat it does
tmux new -s deployStart a session named deploy.
Ctrl-B, then dDetach. It keeps running without you.
tmux lsList sessions.
tmux attach -t deployReconnect to it.
Ctrl-B, then % or "Split the window.

Rule of thumb: run anything long on a remote machine inside tmux.

Try it

Up to 15 XP

Audit this SSH setup

A new engineer describes how they work. Click anything that worries you.

My remote workflow (round 1 of 1)Flags found 0/0

Click every suspicious section. There are 3.

I log in to the relay server with SSH. I emailed my private key to the team so they can log in as me. When SSH said the host key had changed, I deleted the known_hosts line and carried on. For the 4-hour migration, I ran it straight in my SSH session on hotel Wi-Fi. I use rsync for backups.

Key takeaways

  • Use SSH keys, and never share the private half.

  • Take host key warnings seriously.

  • rsync beats scp for folders and repeat copies.

  • Run long remote jobs in tmux.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…