Connecting to the Pi
We will be using SSH to connect your laptop to the Pi. You can do this either over wifi or ethernet. Before doing this, we need to get the IP address of the Pi and import your public SSH key onto the Pi.
Direct Control
This is the process to get the IP address of the Pi and import your public SSH key.
This method requires a monitor and keyboard, cannot be used to share files between a laptop and the Pi, and is more difficult to use. However, we need to use this, mainly to import your SSH key. This is also useful in case the network-config isn’t working. Direct control allows you to edit the file that controls this.
To access the Pi’s terminal directly you will need:
- Raspberry Pi 5
- Pi Power Supply (plugged into wall)
- Monitor (plugged into wall)
- HDMI to Micro-HDMI cable
- Keyboard
- Ethernet cable connected to a router (or ethernet port on the wall of the lab) or just connect the Pi to wifi
Simply connect the ethernet (or just use WiFi), micro-HDMI, keyboard, and power supply to the Raspberry Pi. When it boots, you will see the cloud-init running a bunch of things and the Pi’s Ubuntu Server terminal on the monitor.
Running Cloud-init
Power up the Pi and wait for cloud-init to run.
Within about a minute, your Pi should connect to whatever network interface(s)
are described in network-config and you should be able to find it on the
network. If you setup some sort of key-based authentication (such as by
importing a key from GitHub), it may take an extra couple of minutes for
this to be ready.
After the network setup is complete, you should be able to login over SSH if you edited the user-data file to import your SSH key. However if that process failed, then you’ll have to manually import your SSH key.
In particular, please note that you need to have SSH agent forwarding working on your laptop.
You should have already done this under ORCA Setup when you first made your SSH key. You can test that everything is working by running ssh -T git@github.com on your laptop.
When you first login to the Pi, cloud-init may not have finished running. To check the status, run:
cloud-init status --long
There are also logs in /var/log/cloud-init-output.log (you can read with cat or less).
To keep an eye on the entire process, you can run:
watch "cloud-init status --long && tail -n 10 /var/log/cloud-init-output.log"
Expect this process to take a few minutes to complete.
Initial Setup
When you are able to start running commands, run ./initial_setup.sh. This will log to /home/ubuntu/initial_setup_output.log. It may take around 10 minutes to complete. It will automatically reboot your Pi at the end. If you don’t want this, feel free to comment out the last line. If you don’t know where this line is, it is fine to just leave it to reboot.
After this process finishes running, run ping 8.8.8.8 to test if it is connected to wifi/ethernet. If the Pi isn’t connected, it will say “Network is unreachable”. If the Pi is connected, it will start detecting bytes sent by the address. Hit CTRL + C to stop the pinging. It will then give you a report of how much loss there was. You want to have 0 loss.
Not connecting to your wifi/ethernet?
If the Pi isn’t connecting to the wifi, the network-config file might not be formatted properly. One issue that I ran into was using “wlp2s0b1:” instead of “wlan0” under the “wifis:” section. If you run ip link it will list the different formats that it is looking for. In my case, it was looking for “wlan0” for wifi or “eth0” for ethernet.
Here is how to edit your network-config files without having to take the SD card out.
- Run
ls /etc/netplan/. It should show a .yaml. - Run
sudo nano /etc/netplan/FILENAME.yaml. This allows you to open and edit the file. - Change whatever you need to, then hit
CTRL + X, theny, then hit enter. This saves your edits. - Run
sudo netplan applyto apply these changes - Try pinging 8.8.8.8 again to see if is connected now
- You may need to run
sudo reboot
You can log in and run commands directly with the keyboard (no mouse inputs). There is no way to scroll up through this terminal however, so if you want to be able to read a long output from a command you must pipe it into a file (ex. python run.py >> terminal_output.txt), then read the text file using nano.
Importing Your SSH Key
You then need to add this SSH to the Pi. The simplest method is to first add the key to your GitHub account, then import it onto the Pi from there. If you don’t want to set up GitHub, you can add the key directly with a little extra work (though you may have typos which can make it difficult!).
With GitHub:
- You should have already added the SSH key to your GitHub account.
- Run
ssh-import-id gh:<your-github-username>on the Raspberry Pi with the direct control.
If you haven’t yet added your key to GitHub, do the following:
- Create an account on GitHub and sign in.
- In GitHub, open settings and go to the SSH and GPG keys tab and add a new SSH key.
- Name this key whatever you want and paste the key into the correct field.
- Log into the Pi using the direct control method above.
- Run
ssh-import-id gh:<your-github-username>.
Without GitHub:
- Log into the Pi using the direct control method above.
- Open the authorized keys file with
sudo nano ~/.ssh/authorized_keys. - Manually copy your key (starts with ssh-ed25519, ends with your email) into the file
- Hit Ctrl+X followed by Y, then Enter to save the changes.
You should now have permission to SSH into the Pi from your laptop using one of the following methods (wifi or ethernet).
Modify your ~/.ssh/config file (use nano ~/.ssh/config) and add an entry like this enabling SSH agent forwarding (or don’t, you likely already set up SSH agent forwarding on your laptop so I don’t think you need to do this. I didn’t do this and it worked fine for me):
Host 192.168.11.137
HostName 192.168.11.137
User ubuntu
ForwardAgent yes
Note that if your username or host IP address is different, you should adjust it accordingly.
Remote host identification has changed
If you use the same static IP for multiple Pi’s (which, presumably, you only ever use one of at a time), you may encounter an error stating:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
This is because your computer thinks its connecting to a different Raspberry Pi.
You can manually add the fingerprint for the currently connected Pi like this:
ssh-keyscan -H 192.168.11.137 >> ~/.ssh/known_hosts
(This would be a bad idea to do at random for a remote computer. I’m assuming here that you’ve just plugged in a new Pi right in front of you and you know exactly why you’re getting this error. You should only have to do this once per new Pi.)
General Network Tip
If you ever are struggling and Google another tutorial that uses dnsmasq or dhcpcd, check if your Pi uses NetworkManager!!! It is a lot easier to use than the two mentioned above (in my opinion). The newer Raspberry Pi’s use this and ignore the dnsmasq and dhcpcd.SSH over Ethernet:
This is a good method because the Pi is not required to be connected to a router or Wi-Fi network. However, it does take a bit of setup the first time. This method can be good if you are outside with no access to internet. There is also the SSH over Hotspot method which is also good when you are outside and you won’t need ethernet cables.
For this method, you will need:
- Laptop connected to Wi-Fi
- Raspberry Pi 5
- Pi Power Supply (plugged into wall)
- Ethernet cable
- Ethernet to usb-c adapter (if your laptop doesn’t have an ethernet port)
Plug the power supply into the Pi and plug one end of the ethernet cable into the Pi, and the other into your laptop.
Connect your laptop to any Wi-Fi network.
If your laptop’s public SSH key is not already on the Pi, see the section above for how to add it. (Using direct connect)
If this is your first time setting up this method, you will now need to enable internet sharing on your laptop. If you have done this before, then skip this step.
a. Windows:
- i. Open Control Panel and go to the Network section.
- ii. Find the Wi-Fi connection and right click on it, then go to Properties.
- iii. At the top, click on the Sharing tab.
- iv. Check “Allow other network users to connect…”
- v. In the dropdown, select “Ethernet2” (not the ethernet for WSL).
- vi. Apply the changes.
b. Linux:
- i. Install Network Manager Command-line Interface (nmcli) with
sudo apt install network-manager. - ii. Find the connection name with
nmcli con show. Find the entry with type ethernet, it should have a name like “Wired connection 1”. - iii. Run
nmcli con modify “Wired connection 1” ipv4.method shared.
- i. Install Network Manager Command-line Interface (nmcli) with
If you are on Linux, run
nmcli con up “Wired connection 1”Find the Pi’s IP address on your local subnet.
- a. If you are on Windows, open PowerShell and run
arp -a. You should see an interface for 192.168.137.1 and within that section should be an IP address that starts with 192.168.137 and ends with something other than .0 or .1 (ex. 192.168.137.27). - b. If you are on Linux, then Pi #1 always has the IP 10.42.0.10, and Pi #2 always has the IP 10.42.0.20. If for some reason you cannot find the IP, confirm the subnet is 10.42.0 by running
ip a. Under the enxc… section should say “state UP” and you should see “inet 10.42.0.1/24”. You can then scan the subnet to find the pi by runningnmap -sn 10.42.0.1/24and looking for a device that’s not 10.42.0.1. You may need to restart the Pi and give it a minute to boot.
- a. If you are on Windows, open PowerShell and run
Run
ssh ubuntu@<pi-ip-address>to connect to the Pi. You can now run commands on the Pi, and transfer files to and from your laptop using SCP (will be explained below).
SSH over Wi-Fi:
This method is nice as it requires less cables and can be used for connecting multiple devices, however you will have to use one of the other methods such as SSH over Ethernet initially to find the Pi’s internet IP address.
ssh ubuntu@<pi-ip-address> on your Pi to SSH connect. If you chose a different username than ubuntu, than replace the command with that. The direct connect and internet connection should already exist since you needed them previously to import your GitHub key. You can get your Pi’s IP address by running hostname -I or ip a (in my opinion, using hostname -I is easier cause you don’t need to hunt for the ip info). If you chose a different login username, replace ubuntu with that.For this method, you will need:
- Laptop connected to Wi-Fi
- Raspberry Pi 5
- Pi Power Supply (plugged into wall)
- Ethernet cable connected to a router (or to the ethernet port on the wall of the lab) if not connecting the Pi to Wi-Fi
- Plug the ethernet and power cable into the Pi and turn it on. Or if the Pi is connected to Wi-Fi just leave it as is.
- If you do not know what the Pi’s current IP address is, you must first use the Direct Control method above to get access to the terminal. You can run
hostname -Iand it will print out the IP address. Another way is when the Pi first boots, system information is printed to the terminal. In the bottom right corner of this message, you should see a section that says “IPv4 address for eth0 (or wlan0): 128.138.189.xxx”. You can also find the IP address by runningip aand looking for the address under theeth0(or wlan0). This address may change each time the Pi is reconnected to the internet. This means you will consistently need direct control to see the IP address unless you set a static IP address. Information on how to do this is below. - Connect your laptop to a wifi network.
- Check if you can find the Pi over the internet by running the command
ping -c 1 your.pi.ip.address. On Windows, this must be done in PowerShell with admin privileges, not WSL. If it says 0 packets received, then either the IP address is incorrect, or you are not on the same network as the Pi. - If your laptop’s public SSH key is not already on the Pi, see the section above (Importing Your SSH Key section) for how to add it.
- Run
ssh ubuntu@your.pi.ip.addressto connect to the Pi. If you chose a different login username, replace ubuntu with that. You can now run commands on the Pi, and transfer files to and from your laptop using SCP (see below).
exit or logout to turn your powershell back to normal.SSH Over Hotspot:
This method is good for the outdoors where there is no Wifi/internet connection. It allows you to SSH into the Pi without internet connection, similar to SSH over ethernet, but you also won’t need an ethernet cable. If you use this method, the Pi will not be able to access a Wi-Fi internet connection at the same time, so you won’t be able to clone the repository or pull from the repository. This setup will require direct control, but afterwards you won’t need direct control again.
For this method, you will need:
- Laptop
- Raspberry Pi 5
- USB keyboard connected to the Pi (direct control)
- Monitor connected to the Pi (direct control)
- Pi Power supply
- This method uses NetworkManager and your Pi’s connections need to be controlled with NetworkManager. Check if your netplan’s renderer is NetworkManager, if not, change it to NetworkManager.
- Run
ls /etc/netplan/. It should show a .yaml. - Run
sudo nano /etc/netplan/FILENAME.yaml. This allows you to open and edit the file. - Change whatever you need to, then hit
CTRL + X, theny, then hit enter. This saves your edits. - Run
sudo netplan applyto apply these changes - Try
ping 8.8.8.8again to see if is connected now. HitCtrl + Cto stop the pinging and check that there is no packet loss. - You may need to run
sudo reboot
- Run
- Run
sudo apt updateandsudo apt update -y - Run
iwconfigto see the names for the different connection tools. We want the wifi one which is commonlywlan0but it may not be the same for your Pi. It will be the one with information of IEEE and ESSID - DEVICE is the name of the wifi device (commonly wlan0). SSID is the name of the broadcast of the Pi. It will be what your laptop connects to. PASSWORD is the password for the connection. Run
sudo nmcli d wifi hotspot ifname DEVICE ssid SSID password PASSWORD - You can check that it has been created by running
nmcli connection show. It will look something like this
NAME UUID TYPE DEVICE
Hotspot 59f9160c-b49f-47a2-ac54-87987f743df2 wifi wlan0
Wired connection 1 9d27eb3e-7657-3a54-ad8a-344cb4bb56e3 ethernet eth0
lo a54edcc4-0ffa-4090-a2b3-081905aee1c5 loopback lo
preconfigured 6e07c33c-9764-4145-af3f-49875c8a9342 wifi --
If you are connected to wifi, you will see that at the top with the wlan0 device while Hotspot’s device will be blank.
- To swap to the Hotspot run
nmcli connection up "Hotspot"and to swap back to your wifi replace Hotspot with whatever the name is for your wifi connection. While swapping connections the Pi may freak out and print an error along the lines ofbrcmfmac: brcmf_set_channel: set chanspec fail, reason -52. This happens whenever the Pi loses connection and isn’t a big issue. - If the putting the hotspot up fails with an error of
Connection: activation failed: IP configuration could not be reservedtry the following steps- Run
sudo nmcli connection modify "Hotspot" ipv4.method shared - Run
sudo systemctl stop dnsmasq - Run
sudo systemctl restart NetworkManager - Run
sudo nmcli connection up "Hotspot" - If this works now, the problem is likely dnsmasq so we need to turn it off permenantly so it won’t turn back on and break the Hotspot when you reboot the Pi.
- Run
sudo systemctl disable dnsmasq - Run
sudo systemctl mask dnsmasq - Run
sudo reboot - Now if you run
systemctl status dnsmasqit should say that it inactive (dead)
- Run
- Since you rebooted the Pi, you may need to turn on the hotspot again with
nmcli connection up "Hotspot". It should say succesfully activated and you should see the Pi’s hotspot when you open your wifi connections on your laptop. You can now connect to this. - Run
ipconfigon your laptop’s powershell after connecting (may be a different command if not on a windows device) and look at the IP address after Default Gateway under the Wi-Fi section. This is the IP address of the PI. - Run
ssh ubuntu@your.pi.ip.addressto SSH into the Pi.
The next steps are optional but makes it so your Hotspot will be the default connection your Pi does. This makes it so if you are outside and need to connect to the Pi, you can do so immediately without needed direct control to swap the network connection from wifi to the hotspot. The default connection for the Pi seems to be Wi-Fi.
- Run
sudo nmcli connection modify "Hotspot" connection.autoconnect true - Run
sudo nmcli connection modify "Hotspot" connection.autoconnect-priority 100 - Run
sudo nmcli connection modify "wifi connection" connection.autoconnect-priority 10Rename “wifi connection” to whatever the name of your wifi connection is. You can check what it is withnmcli connection show. The first autoconnect priority is the higher number.
Now if you reboot the Pi, it will automatically open the hotspot first.
Setting Static IP Addresses
Setting a static IP address makes it very convenient because you won’t need to use direct control to see the Pi’s IP address everytime you want to SSH into it.
Setting a static IP address when the Pi connects to wifi
- Run
hostname -Ito show your current IP. You can use the same one or don’t. - Run
ip r | grep defaultand check the IP that is after the word via. That is your default gateway. - Run
nmcli connection showto find the name of your wifi connection - Run
sudo nmcli connection modify "your wifi name" \
ipv4.addresses your.chosen.static.ip/24 \
ipv4.gateway default.gateway.ip.address \
ipv4.dns default.gateway.ip.address \
ipv4.method manual
or you can put them all in the same line if you don’t put any slashes
5. Turn off the connection with sudo nmcli connection down "wifi connection"
6. Turn back on the connection with sudo nmcli connection up "wifi connection"
7. Now if you do hostname -I it should be the static IP address you chose and you can ssh to it with this IP address
Bugging SSH connection?
If the wifi static IP address bugs out and you can’t ssh into the Pi, try restarting the Pi. Also try setting the ipv4.method back to auto then back to manual withsudo nmcli connection modify "wifi connection" ipv4.method auto and sudo nmcli connection modify "wifi connection" ipv4.method manualSetting a static IP address when the Pi acts like a hotspot
- Swap back to using your hotspot connection with
nmcli connection up "Hotspot" - Run
hostname -Ito check your current IP address. You can chose this to be your static IP address. - Run
sudo nmcli connection modify "Hotspot" ipv4.addresses static.ip.you.chose/24do not leave out the /24. - Turn on and off the hotspot connection with
nmcli connection down "Hotspot"andnmcli connection up "Hotspot" - The IP address should now be static so you no longer have to check the Pi’s IP address with
ipconfigwhenever you connect to the hotspot.
Now you won’t really need direct connection to control the PI because you can always SSH into it from elsewhere. When you SSH into the Pi, you are still able to swap the connection you just need to add sudo to the front. Example sudo nmcli connection up "wifi connection".
Cloning the Repository onto the Pi
You need to be connected to the internet for this to work. Run git clone https://github.com/username/repositoryname to add the uhd-radar github repository to the Pi. If you don’t have the https:// it won’t work. Using SSH (the link that ends with .git) also won’t work because your Pi doesn’t have your laptop’s private key. Don’t give your Pi your private SSH key.
Transferring files to and from the Pi:
The Raspberry Pi 5 unfortunately does not support data transfer (USB OTG) over its USB 3.0 ports, only the USB C port which we currently use for power. Fortunately, we can make use of the SSH connection to send files to and from the Pi using SCP and/or GitHub.
If you have committed changes to the code and pushed them to GitHub, you can just checkout the correct branch and run git pull on the Pi to see them. However, if you are debugging or making small changes to a file that aren’t worthy of a commit, you can send files directly with SCP (secure copy protocol) by running the following command on your laptop.
Send a single file with scp <my-file-path> ubuntu@<pi-ip-address>:<pidirectory-path>
Example:
Windows:
scp sdr\main.cpp ubuntu@192.168.137.10:~/uhd_radar/sdr/Windows:
scp .\Downloads\test.txt ubuntu@192.167.138.131:~/- This pushed from C:\Users\Name\Downloads and put it in /home/username
Linux:
scp sdr/main.cpp ubuntu@10.42.0.10:~/uhd_radar/sdr/
"." in windows and the "~" in ubuntu act the same way. They both make it start in the home directory so you don’t have to type all of it out. The "." for windows puts you in C:/Users/YourName and the "~" for ubuntu puts you in /home/AccountUsername.You can also send a whole folder with scp -r <my-directory-path> ubuntu@<piip-address>:<pi-directory-path>
To send files from the Pi back to your laptop, reverse the two arguments ensuring the first is one or more files, or directory, and the second is a directory for where the file should go.
Example:
- Windows:
scp ubuntu@10.42.0.10:~/uhd_radar/data/20250716* ~/uhd_radar/data/ - Windows:
scp ubuntu@192.168.137.131:~/test2.txt .\Downloads- This pulled from /home/username and put it in C:/Users/Name/Downloads
If you push or pull a file that has the same name in the other device, the new file pushed/pulled will overwrite the old file.
When using these commands, you are typing them on your laptop powershell. You are either pushing from your laptop to the Pi, or you are using your laptop to pull from the Pi. You can also push from the Pi but that’s a different command.
Installing Miniconda
- First go to Anaconda’s website and scroll to the bottom to download Miniconda. You will want the Linux 64-Bit ARM64 version.
- Once the file is downloaded, you will want to use SCP to get the file onto the Pi. Make sure you have connected to the Pi using SSH. The command might look something like
scp .\Downloads\Miniconda3-latest-Linux-aarch64.sh ubuntu@192.168.137.131:~/. - Within the Raspberry Pi’s terminal, run
bash location-to-file/Miniconda3-latest-Linux-aarch64.shand accept the default options in the installer (select yes when prompted about auto_activate_base, though we will change this later) - After Miniconda is installed, reboot the Raspberry Pi with
sudo reboot now - To ensure it has been installed, run
conda listand you should see a list of the installed dependencies printed out. - We are now going to change one of the default settings with the command
conda config --set auto_activate_base false
Next, read on how to connect the SDR and run some tests.