One of the benefits of having a machine like the RPI is that you can set it up on your home network and access it without having to worry about a keyboard, mouse or monitor.
Combined with the RPIs small size, and the ability to place it in a custom case with a wall mount, these features are what make it one of the most exciting tools for home embedded/smart systems.
The steps below are an introduction on getting your RPI to boot up with ssh access, and allow you to connect to it from another machine on your home network.
So what is ssh? In brief ssh (secure shell) is a method that allows us to log into other machines over the network, most commonly through a command line tool (for those of you with a Mac you can do this via the Terminal). Once logged in, depending on our permissions we can then perform actions on the machine we are connected to.
For a deeper more complex technical evaluation of ssh you can read the wiki article here.
For the purposes of configuring our RPI (and later using it as a controller) we are going to be setting up ssh access so we can work on the machine remotely.
In my specific case, this is born from the fact that my router is nowhere near my TV set so trying to configure the RPI with a monitor, but without network access is going to be impossible in some cases i.e. installing HTSQL.
Steps to set up
Fist of all connect your RPI up to its power supply, monitor and keyboard. Then log in.
At this point you may want to set the date of your RPI if you haven’t done so already.
By default the keyboard is set up to be UK format, so the @ is actually the ”
To set the date:
sudo date –set “23 APR 2012 16:01”
Next you will need to set the RPI to start ssh when it boots. To do this follow the next steps:
sudo cp bootenable_ssh.rc boot.rc
The above copies bootenable_ssh.rc and creates a second version called boot.rc. The boot.rc version is then loaded when you start your RPI up.
Now follow the next steps:
- cd /etc/network
- vi interfaces
By default vim isn’t installed on the RPI, so if you haven’t taken the step to install it, you’ll need to use vi to edit the interfaces file.
You’ll need to edit the settings in the interfaces file as follows:
Add eth0 to this line: insert eth0 so : auto lo eth0
Change iface eth0 inet dhcp to iface th0 inet static
- Now add:
address 192.168.0.202 netmask 255.255.255.0 gateway 192.168.0.200
Finally save the file – press : then type x and hit enter to save and exit
The above steps have now added configuration to tell the RPI to run on a static IP address on your local network.
Testing the above worked
You can now log out of your RPI and power it down.
Next, boot the PI back up with your network jack attached. Your PI should now boot with ssh enabled.
I plugged my PI directly into my Cisco E4200 router. I then logged into it via 192.168.1.1 in my web browser (type http://192.168.1.2 into the address bar) – note this may be different on your home network depending on how you have configured it.
If you have a Windows machine for example and your router is plugged into that, you can run:
Now look for Default Gateway, this will give you the IP address that the router should be running on.
Once your PI is powered up and booted (you should also see a yellow light, indicating you are on the network) you can shell (ssh) into your server.
The fixed IP address you assigned may not work. To test if it did try:
If this does not work, log into your router and check the DHCP Client table. Most of the devices I run on my network have a client name e.g. kindle-xxxxxxxxxx.
You may now see a device appear in the list with no name. To confirm which device is your RPI, you can try disconnecting it, refreshing the DHCP client table, reconnecting it and then refreshing again. The new device added to the list is probably your RPI.
Next, take the new IP address from the table and shell into the machine (via Terminal, console, Cygwin or whatever you are using):
This gave me the authenticity message which I accepted. I then entered the default password for the PI, and presto! I am now logged in.
So I need to investigate how to ensure the static IP is always picked up, I’ll blog a separate post on that for those of you having problems.
For the moment we now have an easy way to get access to the PI without a monitor and can go ahead and install whatever packages we need.