Connect to your Raspberry Pi from Anywhere in the World with SSH and VNC
Learn how to access, control, and manage your Raspberry Pi remotely using SSH and VNC. Enjoy the freedom of accessing your Pi from anywhere with an internet connection! …
Updated August 24, 2023
Learn how to access, control, and manage your Raspberry Pi remotely using SSH and VNC. Enjoy the freedom of accessing your Pi from anywhere with an internet connection!
There are many reasons why you might want to access your Raspberry Pi remotely, including:
- Monitoring system performance from afar
- Controlling your home automation or security systems without being physically present
- Troubleshooting issues with your Pi when you’re not near it
- Developing software for your Pi while you’re on the go
Fortunately, Raspberry Pi offers two convenient remote access methods: SSH (Secure Shell) and VNC (Virtual Network Computing). Both allow you to connect to your Pi from another device over a network, but they have different use cases.
Setting Up SSH Remote Access
- First, ensure that your Raspberry Pi is connected to the internet with an Ethernet or Wi-Fi connection. You can check this by running
ifconfig
in the terminal and verifying that you have an IP address. - Enable SSH on your Pi by editing the
/boot/config.txt
file:- Open the file with a text editor using
sudo nano /boot/config.txt
. - Add
# Enable SSH
at the bottom of the file and save it (Ctrl + X
, thenY
, thenEnter
).
- Open the file with a text editor using
- Reboot your Pi by running
sudo reboot
to apply the changes. - On your local computer, open a terminal or command prompt and type
ssh pi@<your_pi's_ip_address>
. Replace<your_pi's_ip_address>
with the IP address of your Raspberry Pi (you can find it by runningifconfig
on the Pi). - You will be prompted to enter the password for the default user “pi”. The default password is “raspberry”. After entering the correct password, you should see the command line interface of your Pi!
Now you can run commands and manage your Raspberry Pi remotely using SSH. Some useful commands include:
top
to monitor system performancesudo apt update && sudo apt upgrade
to update your softwarenano /path/to/file.txt
to edit a text file (useCtrl + X
thenY
andEnter
to save changes)
Setting Up VNC Remote Access
VNC is useful for controlling the graphical user interface of your Pi remotely. This can be helpful if you want to run programs that require a GUI, such as web browsers or video streaming software. To set up VNC:
- Install the necessary packages by running
sudo apt install x11vnc xorg
. - Create a password for VNC by running
x11vnc -storepasswd
. Enter and confirm your desired password when prompted. - Edit the
/boot/config.txt
file again usingsudo nano /boot/config.txt
and add these lines at the end:# Enable VNC server startx x11vnc -forever -usepw -no6 -auth guess
- Reboot your Pi with
sudo reboot
. - On your local computer, download and install a VNC viewer such as RealVNC or TigerVNC.
- Enter the IP address of your Raspberry Pi and the password you created earlier in the VNC viewer to connect. You should now see a graphical representation of your Pi’s desktop!
With both SSH and VNC, you can access your Raspberry Pi remotely from any device with an internet connection. These methods are particularly useful for those who travel often or work from different locations, as they allow you to manage your Pi without having to be physically present at its side.