SSH, VNC and copying files
You do not need the lab monitor to use the Pi. From your laptop on the same network:
- SSH gives you the Pi's terminal.
- VNC shows the Pi's whole desktop in a window.
- scp / SFTP copies files both ways (the best way to back up your work).
First get the Pi's IP on the Pi: hostname -I (lab: 172.16.x.x). It can change every lab.
SSH
Windows PowerShell, macOS and Linux all have ssh built in:
ssh pi@172.16.5.23
The first time, type yes to trust the Pi, then the password (nothing appears while you type). You get the same prompt as the Pi's terminal. exit leaves.
ssh pi@raspberrypi.local also works on some networks, but not if several Pis have the same name, which is usual in a lab where every card was cloned from the same image. Use the IP.
What stops when you disconnect
Programs you start in an SSH session stop when the session ends (closing the window, Wi-Fi drop, laptop sleep). For a script that must keep running:
nohup python app.py > app.log 2>&1 & # keeps running after you disconnect; output goes to app.log
Or make it a service (how).
Copying files
From the laptop's terminal (not inside SSH):
scp myscript.py pi@172.16.5.23:/home/pi/ # laptop -> Pi
scp pi@172.16.5.23:/home/pi/mysensor_backup.sql . # Pi -> laptop (. = this folder)
scp -r pi@172.16.5.23:/home/pi/templates . # a whole folder
With a window instead: WinSCP (Windows) or FileZilla (protocol SFTP, port 22), using the Pi's IP, pi and the password. VS Code with the Remote - SSH extension lets you edit files on the Pi directly.
VNC (remote desktop)
- On the Pi:
sudo raspi-config→ Interface Options → VNC → Yes. - On the laptop: install RealVNC Viewer (or TigerVNC).
- Connect to the Pi's IP and log in as
pi.
Black screen or "cannot currently show the desktop": no monitor is attached and the Pi chose a tiny or no resolution. sudo raspi-config → Display Options → VNC Resolution, pick 1280x720, reboot.
Keys instead of passwords (optional)
On the laptop:
ssh-keygen -t ed25519 # press Enter at each question
Then copy the public key (~/.ssh/id_ed25519.pub, on Windows C:\Users\YOU\.ssh\id_ed25519.pub) into /home/pi/.ssh/authorized_keys on the Pi (one line per key). On macOS/Linux ssh-copy-id pi@172.16.5.23 does it for you.
Key logins fail if the permissions are too open. On the Pi: chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys.
Errors
| Error | Meaning and fix |
|---|---|
Connection timed out | Wrong IP, different network, or the Pi is still booting. Check hostname -I on the Pi and that both are on the lab Wi-Fi. |
Connection refused | The Pi is reachable but SSH is off: sudo raspi-config → Interface Options → SSH → Yes. Or sudo systemctl enable --now ssh. |
Could not resolve hostname raspberrypi.local | Name lookup does not work here. Use the IP. |
Permission denied, please try again | Wrong password or user name (pi, lower case). |
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! | That IP was a different Pi or card last time (normal in a lab). On the laptop: ssh-keygen -R 172.16.5.23, then connect again. |
Host key verification failed | Same as above. |
| Connection freezes after a while | Wi-Fi dropped or the laptop slept. Reconnect; running programs in that session were stopped. |