(Almost Painless) SSH Setup Guide
Prepared by Qingqing Ni
1. Student Guide: Set Up an SSH Key
Info
SSH keys allow you to connect to the Raspberry Pi without entering the account password every time.
Each Ubuntu VM should generate its own SSH key. Do not share your private SSH key with anyone.
Complete the following steps inside your Ubuntu virtual machine.
Step 1 — Generate an SSH Key
Open a terminal and run:
Replace <YYYY> with the current academic year and <S> with the current semester.
For example, for Academic Year 2026/2027, Semester 1:
The comment allows the teaching team to identify and clear student SSH keys from a particular semester.
You will see a prompt similar to:
Press Enter to use the default location.
You will then be asked for a passphrase. For the lab setup, you may press Enter to leave it empty.
This creates two files:
id_ed25519is your private key. Do not share it.id_ed25519.pubis your public key. This is the key that will be added to the Raspberry Pi.
Step 2 — Copy Your Public Key to the Raspberry Pi
Run:
where X is the number assigned to your Raspberry Pi.
Alternatively, you may connect using its IP address:
Enter the password 030609 when prompted.
You should only need to enter this password once.
Step 3 — Test the Connection
Run:
or:
You should now be able to log in without entering the Raspberry Pi password.
Tip
Using a Different VM or Computer
SSH keys belong to the machine or VM on which they were generated.
If you:
- create a new Ubuntu VM,
- reinstall the VM, or
- connect from another computer,
generate a new SSH key on that machine and repeat the setup above.
Do not copy your private key between machines unless specifically instructed to do so.
2. SSH Shortcuts
Info
You can create SSH shortcuts in your Ubuntu VM so that you do not need to type the full hostname or start the ROS 2 Docker container every time.
On your VM, open:
Add:
Host <nickname>
HostName balanceX.local
User balance
Host <nickname>-ros
HostName balanceX.local
User balance
RequestTTY force
RemoteCommand bash -lc 'docker start ros2_humble >/dev/null 2>&1 || true; docker exec -it -w /home/ros2_ws ros2_humble bash'
Replace <nickname> with your preferred shortcut and X with the number assigned to your Raspberry Pi. For this manual, we will use car as the shortcut.
Set the correct permission for the SSH configuration file:
You can now use:
to open a normal SSH session on the Raspberry Pi.
Or use:
to enter the ROS 2 Docker container directly at:
The car-ros shortcut will start the ros2_humble container automatically if it is not already running.
3. Clearing Student SSH Keys
All SSH public keys added to the balance account are stored in:
Each public key normally occupies one line. Student keys generated using the instructions above will end with a comment such as:
Check Existing Student Keys
Before removing anything, you can list the student keys for a particular semester using:
For example:
This only displays matching keys and does not modify the file.
Remove Student Keys for the Semester
To remove all student keys for a particular semester, run:
For example, to remove all keys labelled AY2627S1:
This removes only lines containing:
Other SSH keys in the file are left unchanged.
You can verify that the student keys have been removed using:
If there is no output, no matching student keys remain.
You can also inspect all remaining authorised keys using: