Ubuntu Linux for Robotics · Lesson 13 of 96
SSH: remote access
Logging in to a robot, keys instead of passwords, the config file and port forwarding.
Estimated time · 45–75 min
Learning goals
What you will understand
- Explain ssh: remote access in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
SSH gives you a secure terminal on another computer, such as the computer inside a robot. Install the server with sudo apt install openssh-server and connect with ssh user@address. The first connection asks you to trust the host key; later a changed key is a warning that must not be ignored.
Use keys instead of passwords: ssh-keygen creates a private key (keep it secret) and a public key, and ssh-copy-id installs the public key on the robot. A ~/.ssh/config entry gives the robot a short name. Forward a port with -L to reach a service that runs only on the robot.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the ssh: remote access commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
sudo apt install openssh-server
# On the robot: install the SSH server.
ssh-keygen -t ed25519
# On your laptop: create a key pair (protect it with a passphrase).
ssh-copy-id robot@192.168.1.50
# Install your public key on the robot.
ssh robot@192.168.1.50
# Log in; no password is needed after this.
ssh -L 8080:localhost:8080 robot@192.168.1.50
# Forward local port 8080 to a web service on the robot.
printf 'Host robot\n HostName 192.168.1.50\n User robot\n' >> ~/.ssh/config
# Create the short name so you can type ssh robot.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · The robot's computer
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for SSH: remote access. Expected result: created
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
d=$(mktemp -d)
# TODO: create an ed25519 key pair in $d/key with an empty passphrase (-N "") and no prompts (-f)
test -f "$d/key.pub" && echo createdExpected output
createdStuck? Show the full solution (try it yourself first)
d=$(mktemp -d)
ssh-keygen -q -t ed25519 -N "" -f "$d/key"
test -f "$d/key.pub" && echo createdExpected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Set up key-based login to a virtual machine or a robot, disable password login in /etc/ssh/sshd_config (keep a second session open while testing), and add a config entry so ssh robot works.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.