While both of those methods work well, they require you to be on the same network. In other words, they work when you and your Pi are both at home.
So what do you do when you want to connect to your Pi and it’s not with you?
If you want to leave your Pi at home and work on it from your laptop at a coffee shop or a friend’s house, you’ll need to connect over the internet.
The big problem
The problem is that connecting to your Pi over the internet often involves exposing a port on your router to the World Wide Web which is potentially a massive security risk.
If you Google around for remote access solutions, you’ll undoubtedly come across port forwarding (also known as SSH tunneling). And every time you find a tutorial about port forwarding, you’ll also read a passage about all the associated security risks.
Now, I don’t know about you, but I’m not a security expert. I’d rather not take the risk and hope that I’ve secured my Pi properly. While the odds of an attack are slim, the potential damage is catastrophic i.e. someone getting into your Pi and then connecting to your computer to do whatever they want.
After learning about this, I thought to myself, “there has to be a better way…”
Well, the good news is that there is!
There are actually two really good ways to connect to your Pi over the internet without using port forwarding or exposing your devices to hackers.
Two ways to securely connect online
I’ll give you both solutions now and then you can follow the steps below to learn how to use them.
Solution #1: VNC Connect
You probably already know you can use VNC to connect remotely from the same network, but they also have a free cloud connection service. You’ll use the same VNC Viewer app, but instead of connecting directly to the Pi, you’ll connect through their servers for authentication.
Solution #2: Remote.it
Remote.it is a platform designed for handling remote device connections over the internet in a way that is totally secure and doesn’t require port forwarding. The reason you’d use this service is to access your Pi with SSH. With Remote.it, you can run terminal commands from your computer like you normally would when connecting directly to your Pi with SSH.
Regardless of which you choose, both of these services are free for personal use. You won’t need to pay unless you’re using these products to run a business.
I’m not affiliated with these companies and haven’t been compensated for this article. These are simply the best tools I found for remote accessing a Pi from the internet.
How to use VNC for cloud connections
If you haven’t used VNC before, follow the steps in this tutorial first. You’ll learn how to connect to your Pi from your computer while on the same network.
Once you’ve done that, the next step is to create a RealVNC account. To do that, open the VNC Viewer app on your computer, click the Sign in button at the top-right, and then click the “Don’t have an account” link.
You’ll be taken to a simple account creation page where you can signup.
Once you’ve created your account, scroll to the bottom of your account page and click the Activate button in the “Home” subscription.
This will enable free cloud connections for your account.
Back in the Viewer app, login using the account credentials you just created. They’ll send you a confirmation email. Click the confirmation link which will open this page where you can click the “Authorize sign-in” button to finish authenticating your device.
The next step drove me totally nuts.
You’ve registered your computer as a device and now you need to register your Pi. To do that, you have to sign-in to your VNC account from the VNC app on your Pi. However, you can’t login to your VNC account when accessing your Pi remotely. In other words, you need to have your Pi plugged into a monitor and use it directly or the sign-in link won’t even show up in the VNC app.
Once you’ve got your mouse, keyboard, and monitor plugged into your Pi, you’ll see the sign-in link in the VNC server app. Login using your new account credentials and authorize the Pi as a device.
Once you’re finished, restart VNC Viewer on your computer and when you check the team tab, you’ll see the Pi listed.
Double-click the Pi to start the connection.
When connecting remotely, you’ll have to enter your Pi’s username and password each time. Your username will be “pi” and the password is the one you created for your Pi during setup.
After logging in you’ll be connected to your Pi.
You can now access your Pi’s desktop from anywhere over the internet without compromising on security.
Test it out
To test if it’s working, you can connect to a nearby xfinity hotspot or other public wifi. Or, if neither of those are an option, you can tether to your phone and then connect that way.
The important thing is that your Pi is connected to your home network and your computer is not.
Fixing the “cannot currently show the desktop” error
You are likely to see this error next time you try to remote connect after restarting your Pi. There are two steps required to fully address this issue.
The first solution
If you turn off or restart your Pi, the VNC server won’t automatically start when your Pi boots, and if you try to connect with VNC, you’ll see the error quoted above.
If you don’t have SSH access over the internet, this is a major problem because you can’t access your Pi to start the server. While Remote.it is a good option here, there’s also an easy way to start VNC at boot.
Run the following command to open the configuration menu:
You’ll see a screen like this:
Navigate to the Interfacing Options and then select VNC.
Hit Enter to enable the VNC Server.
I know what you’re thinking: “Didn’t I already do this?”
If you enabled VNC from the GUI, it doesn’t start at boot. But if you enable VNC from the terminal using these steps, it will start at boot. It’s a bit odd, but it works.
After doing this, you can reboot your Pi from VNC Cloud and still re-connect.
There’s one more step to ensure the “cannot currently show the desktop” error doesn’t reoccur.
The second solution
Even with the server running, you still might get an error.
When connecting on the same network, you can add “:1” to the IP to specify a virtual desktop, but you can’t do this for a cloud connection, and for some reason, when using the default resolution on your Pi, VNC expects there to be a monitor to replicate, thus not creating a virtual desktop for you to view.
Luckily, the solution is painless.
Open the configuration menu again using this command:
Key down to to the Advanced Options and hit Enter. In the Advanced Options, open the Resolution menu.
In the screen resolution menu, the Default resolution will currently be set. You can select any resolution you want as long as you change from the Default resolution.
Once you’ve changed your resolution, restart VNC viewer, and the next time you try to connect to your Pi the virtual desktop should work.
With these two fixes added, you can reliably connect to your Pi over the internet using VNC.
While a virtual desktop is a great way to work on your Pi, nothing beats full SSH access. And yes, you can use VNC to use the terminal app on your Pi, but I don’t think I’m alone in preferring to run the terminal on my Mac rather than through VNC.
Remote.it makes this easy.
How to use Remote.it
Remote.it is an awesome tool for connecting to your Pi from a remote network. It lets you create a secure connection to your Pi without utilizing SSH tunneling.
When you click the Sign Up link, you’ll be take to a simple account creation page.
Once you create your account, you’ll be logged into a dashboard where you can manage all your registered devices.
Click the Add Device button and then select the right download package for your OS.
Press the Download Desktop App button on this screen and then carry out the installation as you would for any downloaded application.
Once the app is installed on your computer, boot it up and you’ll see a window like this.
Before you continue, make sure your Pi is turned on and connected to your Wifi network. Then click the Install Service button to enable the background connections Remote.it uses.
When the process is complete, you’ll see a new page where you can navigate through the devices connected to your network.
Find your Raspberry Pi and click Register. You’ll be taken to a new page that asks you to name your device and select which services you’d like to enable.
When you’re ready, click the Register button to add the Pi to your account, and when finished, you’ll see this screen where you can review your settings.
You can now safely close the Remote.it app used to create this connection.
Back in your browser, refresh the Devices page and you should see your Raspberry Pi listed there. It will also have this green Connect button you can click to choose a connection service.
If you select SSH, you’ll see this window in a moment with your SSH connection details:
Copy & paste the “For pi username” command into your terminal and you’ll connect to your Pi. Then just enter your password as usual and you’re in.
Thanks to the initial setup process, you have a secure connection between your computer and your Pi through the Remote.it servers which verify the devices are allowed to communicate with each other. Even if someone else were to get a hold of one of these ssh commands (which don’t stay the same anyway), Remote.it would block them since their device is not registered to your account.
Now that you have Remote.it set up, it only takes a minute to SSH into your Pi from any remote network.
Finally, access your Pi from anywhere!
Never again will you be stranded without access to your incredible Raspberry Pi.
With the two approaches outlined here, you have complete access to your Pi from anywhere in the world. You can leave it plugged in safely at home and work exclusively from your laptop.
While I suspect Remote.it is going to be a reader favorite due to its SSH feature, RealVNC has it’s practical applications too. If you’re not too comfortable with the command line yet, it can be much easier to navigate the file structure and perform other tasks with the GUI using VNC.
Thanks for reading this tutorial, and please post any comments or concerns you have in the comments section below.