You can connect to your Raspberry Pi from another computer anywhere in the world over the Internet. One method is to use port forwarding. Port forwarding requires you to change the configuration settings on your router. You must configure your router to forward the Internet traffic delivered to your public IP address on a specific TCP port number, to automatically route to the local network IP address of your Raspberry Pi. Most routers have this feature available through their configuration webpage. However, every router is different and there is no single set of instructions that applies to every router in use today. You will need to refer to the instruction manual for your router. The configurations can be tricky if your Pi is behind a firewall, or behind more than one router. One disadvantage of port forwarding is that it leaves a TCP port on your public IP address open on the Internet. This is a well known security vulnerability and must be managed carefully.
One alternative method to port forwarding is the use of Weaved services. Weaved is free software you can install on your Raspberry Pi that allows you to connect to your Pi from anywhere over the Internet. Weaved provides an IoT (Internet of Things) Kit for the Raspberry Pi. The kit provides really simple tools for connecting your Pi to the cloud, receiving notifications, and turning your Pi into an Internet of Things Kit. They offer a few services that let you connect from a distance:
- SSH on port 22 – You can login to your Pi from anywhere over SSH.
- Web (http) on port 80 – You can view a web page your Raspberry Pi serves up from anywhere.
- WebIOPI on port 8000 – Control your Raspberry Pi GPIO pins using their custom software.
- VNC on port 5901 (tested with tightvncserver)
- A custom TCP service on your port of choice.
Setup Weaved on the Raspberry Pi :
1) Get a Free Account. You can get a free account at Weaved on their website. At the time of our writing, the service is in Beta and everything is free.
2) Fire up your Raspberry Pi and connect to the internet.
3) Download the Weaved Software to your Pi.
4) Make the installer executable:
chmod +x weaved-nixinstaller_1.2.13.bin
5) Launch the installer:
6) Choose one of the following services:
- SSH on port 22
- Web (http) on port 80
- WebIOPi on port 8000
- VNC on port 5091 (tested with tightvncserver)
- A custom TCP service on your port of choice
7) Enter the e-mail address and password for your Weaved account. Then Enter an alias, or nickname for your device.
Connect with Weaved from Anywhere
To test the connection to your Raspberry Pi from your browser, go to the device list, find the line with your Raspberry Pi's alias, and click on the device name to connect.
If the service you installed uses the http web protocol, the connection will open directly in your browser. Otherwise, a popup window will appear with a web address that you can copy into your application's connection window.
Using the Weaved SSH connection>
When you have set your Pi up for SSH on port 22, and you click on "Connect" on the Device List, after a few seconds you'll get a popup window. In the middle is a string you should highlight and copy.
It will be something like this:
To use this as part of an SSH command line (e.g. Linux or Mac terminal window), type the command like this:
$ ssh -l pi proxy7.yoics.net -p 38138
pi is the username,
proxy7.yoics.net is the host, and
38138 is the port.
If you are using an SSH client, then the first part (before the colon):
should be entered as the "host name" and the second part:
should be entered as the port.
After you log in, you'll probably see this message:
The authenticity of host '[proxy7.yoics.net]:38138 ([22.214.171.124]:38138)' can't be established.
ECDSA key fingerprint is 7d:36:98:f2:5a:d9:6e:d3:11:57:bd:d2:f9:30:a8:e9.
Are you sure you want to continue connecting (yes/no)? yes
You should answer 'yes' here.
Warning: Permanently added '[proxy7.yoics.net]:38138,[126.96.36.199]:38138' (ECDSA) to the list of known hosts.
You will get this message each time you reconnect because the address you are given changes each time you click on "Connect" at your Device List.