Enabling remote SSH on Raspbian (Raspberry Pi)

I’m off to visit some family this weekend and I’d like to be able to use my Raspberry Pi while I’m away, so this will involve setting up SSH and making it visible remotely (outside my home network). I’d like to access it from my Android phone.

Enable SSH on Raspbian

Firstly install the SSH service by running this command:

sudo apt-get install ssh

Then start the service:

sudo /etc/init.d/ssh start

And now we want to make it start every time the Pi boots:

sudo update-rc.d ssh defaults

Next up, try a reboot and confirm everything works. Reboot by running sudo reboot.

Connecting to the Pi over SSH

To connect, you’ll need to know the IP address of your Pi. You can get that by typing sudo ifconfig. There will be a line starting “inet addr: …”, and the IP address is next to that.

I have connected to the Pi from my windows machine using PuTTY. Download here. Once you’ve got PuTTY installed, put it in a sensible location on your hard drive and open it. Fill in your Pi’s IP address, and in the Saved Sessions section, type “Raspberry Pi”. Click Save.

 You should be able to click Open and log in.

For convenience, I created a shortcut on my desktop that would open the session directly. Right click your desktop, and click Create Shortcut. Browse to putty.exe and create it. Then right click on the shortcut and go to Properties. Change the Target to this:

"C:\path\to\putty.exe" -load "Raspberry Pi"

 SSH from your Android phone

I installed a great app called ConnectBot. I tried a couple and this was the best. It’s open source and doesn’t have any ads. When you open it, just type in the address in the format “pi@:“. It’ll prompt you for your password.

Allow access from the internet

OK, I don’t recommend this. Everything up to now is in your own home network and is pretty much a walled garden, safe from bad people. Once you allow access from the internet, you’re potentially opening yourself up to hackers and I don’t have the knowledge to give proper security advice.

That said, I do know the first step is to change your password. Use the command passwd.

Next you need to open port 22 on your router, and set it to forward to your Raspberry Pi. This means that requests from the internet on that port will automatically go to the right place. On my Sky router the set up looks like this:

Next you will want to set the IP address of your Pi to be static, so that it doesn’t change when you reboot. In your router interface, check the list of attached devices and note your Pi’s MAC address:

Then add an entry to the list of reserved IP addresses:

Now you should be able to SSH into your Pi from your laptop (using PuTTY) or phone (using ConnectBot) and instead of entering the 192.168.0.x address, you can use your public broadband IP address.

Finally, if you don’t have a public static IP address (in other words, your ISP keeps changing your IP address) then how do you know what it is? You need to set up a DNS service on your Pi that will regularly check what the network public IP address is, and keep a domain name up to date. Then you can connect using a domain name instead of an IP and it’ll automatically resolve to the correct IP. There are lots of ways to do this – click here for some ideas.

Raspberry Pi media PC with XBMC

What to do with a £30 computer? I’ll get to writing some code for this thing after Christmas. For now, it’ll make a nice media PC. Here are all the details of what I went through to get this up and running.

You will need

  • Raspberry Pi
  • Power supply – a micro USB adapter (my samsung phone charger worked fine). Needs to be 5v and at least 700mA.
  • SD memory card. Make it 2GB or more. I bought this one.
  • USB keyboard (not strictly needed but it’ll be handy now and again)
  • Ethernet connection

Operating System

You could use Raspbian, OpenELEC or Raspbmc. They’re all Linux based and any one would do. Raspbian is the standard OS for the Pi, OpenELEC and Raspbmc will make running XBMC (XBox Media Center) easy. I went for Raspbmc. They’re all super easy to install. For Raspbmc, go here for the download. It just involves sticking the SD card into your laptop and running an installer to get the OS on to the card. Stick the card into your Pi, connect everything up, and voila.

It all seemed to work perfectly for me but keyboard input stopped working after about a minute, every time, and needed a reboot. This would be followed a few minutes later with the power going off. Now, if something goes wrong, and it will, you’ll need to start a trial and error process to narrow down what’s wrong. The Raspberry Pi forums are a great source of help and helped me realise that my power supply was dodgy. This quote sums it up:

This is often due to either (or both) a bad power supply (power supplied much below advertised one), power cable (someone compared a lot of them to wet rope, not ideal for conducting electricity), keyboard (some have power requirements much higher than the 100mA the Pi can supply, this is never listed in their specs, and can vary by production batch for off-brands), or mouse (ditto).

I switched it with my wife’s phone charger which worked perfectly (mine was from ebay – may have something to do with it). Trial and error is the key.

Next problem: audio didn’t work via the HDMI cable into my TV. Cue a change to the Raspberry Pi’s configuration file. This is a text file in the root of your SD card called config.txt containing a list of key-value pairs for configuring various options. I fixed my audio problem with a clue from this forum thread – adding these options to the config.txt:


Check this page for an explanation of those config options. I probably only needed the hdmi_drive option but I’m too lazy to test them individually.

Spot the Pi. Maybe a case is in order…

Now to remote control. You can use a lot of “one-for-all” type remotes, I wanted to use my phone. The official XBMC Remote doesn’t work with the latest XBMC (!) as the HTTP API has been deprecated and removed. Luckily, there are lots of better options available on the Android (and iOS) app stores. I used Yatse. Yatse is VERY slick – it detects the XBMC instance on your home network quickly and is easy to use.

Next up, BBC iPlayer and ITV player. There are lots of others available. The iPlayer app is actually better than the official one on my Blu-ray player as it gives live streaming too. To get it from your computer to the Pi, you need to create a shared folder that the Pi can see. I shared C:\xbmc with a new user called xbmc. You could just be lazy and share it with the ‘Everyone’ group. Copy the zip files in there. Next, in XBMC, go to System -> Settings -> Add-ons -> Install from zip file. Select your share from the list (you will need to create it there first and tell it to look at the C:\xbmc folder you created) and select the correct zip file. Then go back to the home screen and select Videos -> Add-ons. There they are!

Pi Store ideas

That’s XBMC up and running. It’s nice to have it up and running, but I imagine I’ll want to start tinkering with the Pi again. I’ll leave you with some ideas for development. Maybe some day these type of apps will end up on the brand new Pi Store!

Web server/downloader:

  • For an electricity worth about £4 a year the Pi is almost cost-free to run 24/7. It could be downloading all your stuff. It would be sweet to have a web interface where you could queue URLs or torrents or whatever and the Pi will download them whenever your connection isn’t busy.


  • It’d be nice to use smart phones as input devices for a game server running on a Pi and the TV. Like a multiplayer skiing game where the phone accelerometer allows you to steer.

Ideas for media pc/backup:

  • Use the Pi for backup. There’s an 8GB memory card which will be more than enough to back up documents at least. For a hardcore backup option, connect a USB hard drive to it.
  • Have a task running on the laptop which copies photos from My Pictures across to the Pi’s pictures folder.
  • App for our Android devices to automatically back up everything to the Pi on a regular basis while on the home WiFi network. Photos will then be browsable.
  • App for the Pi to backup everything on it to cloud storage.

Home automation:

  • Thermostat control. Wire in a tempertature sensor, use a relay for switching. Add a web server and a web app to allow remote access. I’m obsessive about the temperature in my house, so I would be able to chart it all.