If you like to tinker with things, you should get yourself a Raspberry Pi. It’s an inexpensive, credit card-sized, fully operational PC originally intended as an educational tool for children. But being so versatile and accessible, it quickly became a great tool for hackers and electronic DIY enthusiasts.

I have a Raspberry Pi, but no HDMI monitor or HDMI-VGA adapter. I do, however, have access to HDMI televisions, but as these are also used by other people I can’t really depend on these for continued access to my RPi. My ideal setup (while I waited on an ordered HDMI-VGA cable to arrive) was to be able to use the RPi without being stuck in one location or having to worry about HDMI monitors, keyboards, mice, and so on: I think that defeats the whole small and mobile ethos of the RPi. What I wanted was this:

  • Automatic login/no login to the Raspberry Pi when it powers up
  • Connect to the home WiFi network
  • Email me its IP address so I can connect via ssh from my laptop or other device

Simply: I wanted to power up the RPi in the living room and be able to use the RPi from my bedroom straight away. That’s all.

This post is intended as a guide for those who want to have easy ssh access to their RPi using another device on the same network. 

This is a fairly straightforward thing to set up, but as I’m not a computer expert it took a bit of reading to figure out how to do it. Note that for this guide you will need a compatible USB WiFi dongle (I use an inexpensive Comfast CF-WU720N) but you don’t necessarily need an ethernet connection, as some guides online state.

Getting Started

First of all, you will need to use a HDMI monitor or TV to get your initial setup ready. You’ll also need a USB WiFi adapter, and a keyboard. Ideally, you should get a USB multi-port thing so you can use a mouse too, but if you don’t have one handy, you can use the keyboard to navigate round (the ‘super’ key below can differ between systems, but it’s likely to be the ‘Windows’ key or similar next to ‘Alt’ on your keyboard).

  • Super + e: Opens file explorer
  • Super + r: Opens a ‘run’ text box
  • Alt + Tab: Switch between open windows
  • Alt + F4: Close whatever window is in focus
  • Tab and arrow keys: Navigate round the dialogue box
  • Use the ‘run’ dialog box (Super + r) to type ‘lxterminal’ and get a command line

I mentioned PuTTY and ssh above. If you don’t know what these are, they’re used to log into a remote machine. You can download PuTTY from here if you use Windows, but if you’re using a Linux system, just type ‘ssh’ followed by the destination IP address, e.g. ssh You will probably use one or the other (depending on your operating system) to connect to you RPi once you’ve worked through all this.

Allowing Logins: OpenSSH Server

If you tried the above ssh command to log into somewhere else, it probably worked. However, you need an ssh server to facilitate logins to your RPi. For this, we will use openssh-server. To download and install it, just run:

sudo apt-get install openssh-server

Simples! If you have any errors or problems running that, try running ‘sudo apt-get update’ first. You’ll need an ssh server like this to allow you to login from other devices.

Automatic Login on Startup

The first thing we’ll do is to stop the RPi for asking for login details. Start ‘lxterminal’ and run the following command:

sudo nano /etc/inittab

Look for ‘1:2345:respawn:/sbin/getty 115200 tty1’ (or similar, once it has ‘1:2345’ at the start; the rest wasn’t exactly the same on my RPi) and put a # at the start of it to comment it out. Underneath that line, add:

1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

Press Ctrl+x to exit, and then hit ‘Y’ and enter when nano asks if you want to save the file.

If you reboot the RPi now, it should login automatically without asking for credentials.

Setting Up WiFi

When you login to your RPi, start the x server by typing startx.

Comfast WiFi dongle

On your desktop you’ll notice a WiFi Config icon. Open this and with some luck your network should be listed in the dropdown menu. If it’s not, select ‘Scan’ and see if it picks it up. When it find your network you can connect to it.

In my case, there was no network showing up in the list, so I had to add it automatically.

First of all, check that the WiFi dongle is enabled. If it’s plugged in and lights on it are flashing, you’re probably good to go, but it’s a good idea to check anyway. At a terminal, run the command:

sudo nano /etc/network/interfaces

At the very minimum, you should see this:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

The next bit was already in my ‘interfaces’ file, so it meant my WiFi dongle was enabled. If it’s not on yours, add it in:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Press Ctrl+x to exit, and Y and enter to save the file.

Now you need to actually add your network to the configuration. For this you’ll need your network name (the SSID), the passkey used to login, and the encryption method (which is probably WPA).

At the terminal, run this:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

You should see something like the stuff below. If not, copy and paste it in, but change SSID and passkey for your network (and key-mgmt if you’re using something different than WPA-PSK):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Again, close and save the file (Ctrl+x, then Y and enter). Now, reboot your RPi by typing ‘sudo reboot’.

At this point your RPi should reboot, login automatically, and connect to the WiFi network all by itself.

Run ‘startx’ to get a desktop, and run WiFi Config. Your network should be listed as well as being connected to it. Start a web browser and see if you can get to a website, or at terminal type ‘ping google.com’; if you get anything other than an ‘unknown host’ message, you are now connected to the internet.

When I first did this, I found that my WiFi Config kept scanning for networks, but didn’t actually connect to my home network. I went through the tabs on the dialogue box and found a NetworkConfig option. I used this to change ‘Encryption’ to TKIP, and then everything worked fine. The other option is CCMP, and the selection depends on whether your router uses WPA1 or WPA2. If one doesn’t work, try the other. Hopefully you won’t have to do this, but if WiFi Config sees your network, but has trouble connecting, it’s likely to be something small like this.

Sending IP Address Details

The last thing I wanted my Raspberry Pi to do was to simply email me its address on the home network, so I could then use those details to log into it.

To do this, you’ll need to install an SMTP mail server. You might already have it installed, but if not, follow the instructions on this webpage. If you have trouble downloading the packages it lists, try running ‘sudo apt-get update’ and try again.

The .bashrc file contains a list of stuff that your RPi does when it boots up. The final thing we want it to do when it boots up is email us its IP address details. To do this, type:

sudo nano .bashrc

Scroll down to the very bottom of the file and add:

sleep 10
ip addr show > rpi_wifi.txt
mpack -s "RPi IP details" rpi_wifi.txt YOUR_EMAIL_ADDRESS
rm rpi_wifi.txt

The very first line just gets it to wait for ten seconds. I added this just to make sure the RPi had a chance to connect to the WiFi network, but it will probably work just fine without. Close and save the file, then reboot your RPi again.

At this point, your RPi should now login automatically, connect to WiFi, then email you its IP address details.

Check your emails and hopefully you will have an email with all your RPi’s IP addresses. The email will be divided up into different network connection details, but look for the section that starts with ‘wlan0’. In there you’ll find an IP address most likely in the format ‘192.168.x.x’

Connecting Remotely

Use Putty or ssh or your favourite client to login to your Raspberry Pi. Just enter the IP address given, and login using the RPi’s default details (unless you changed them previously): username: pi; password: raspberry. Because .bashrc is run again, you’ll have to wait ten seconds (if you included the delay above) before getting to a command line.

Hopefully, you should now be logged in to your Raspberry Pi. All you need to do when using your Pi is simply plug it in. It will do everything itself, and when it’s ready to go you’ll get the IP address to login.

Note that if you want to add a new network, you’ll have to add a new network{} section in wpa_supplicant.conf containing the new SSID and passkey, etc. Alternatively, just change the details already in there. Remember that you will need a monitor and keyboard to do this, unless you know the details and set it up before you try to connect to that network.

So that’s how I got my RPi set up. It seems like a lot of info but you can do all this in 20 minutes. I’m sure there are much better ways to do it all but so far this works fine for me!