Wednesday 9 April 2014

Connect Raspberry Pi to computer with ethernet cable - Raspberryception

Raspberry Pi
Finally I revived not only the blog but also my Raspberry Pi. As my bachelor thesis dealt with this little machine of course I wanted to have my own as well. I bought it already several months ago and even tinkered a little around with it but since I moved to Sweden I let it more or less sleep in its plastic case - until today! Taking only small steps so far but if anyone of you wants to get a Raspberry Pi him-/herself this little introduction might help to get it up and running. :) In any case this will help myself to memorise how to do stuff. ;)

Happening in the following: Flash SD card, initial config and what I did today: plug to PC and access via ss. Sharing the internet connection and further securing your ssh will follow next time.

  • Flashing the SD card is really easy by following this tutorial so I leave this one out.
  • Initial config can be done at will or following some tutorial from the internet as well so I leave it out as well and concetrate on what I did today: (Only make sure you enabled ssh in the initial configuration.)
  • ssh from Windows (I did not manage to do it on Linux so far as I could not find out how to properly connect to two networks simultaneously): Easiest way is to use puTTy. This allows you to ssh onto the Raspberry Pi using Windows. A normal network cable is sufficient, no crossfire cable needed. Before being able to connect via putty you need to give the Pi a static IP. This works the following way:
    • Put the Pi SD card into your PC/laptop card reader, navigate to the "boot" folder and open the cmdline.txt with any text editor. To the only line in the file add "ip=<ip-of-your-dreams>" without "". Using Windows you will most probably obtain your IP automatically from a dhcp server so enter the IP as 169.254.#.# where you replace the # with a number between 1 and 254. (Should you not connect to the internet via a dhcp server the IP's first two numbers have to match your PC's IP - can be found from Win-Key + R -> type "cmd" -> type "ipconfig" in the black window -> IPv4 from the adapter you use to connect to the internet.) Save the file and plug the SD card back into your Pi. Boot with ethernet cable connected to both your PC and your Pi.
  • Open putty on your Windows machine and under "session" you enter the static IP you just gave to the Pi. For the port use no. 22 if not preconfigured which is the port that is assigned to ssh. If you want to use programmes with graphical interfaces on the Pi you should enable X11 forwarding at the respective place in putty.
That's it! Connect with username "pi" and your password.