Direct Raspberry Pi to computer Ethernet control

Ever found yourself stuck in the wilderness, armed with only an Ubuntu laptop, an ethernet cable, a micro usb power cable and a Raspberry pi – and let’s face it, who hasn’t been in such a scenario? Well be stuck no more!

It’s possible to directly SSH into the Pi only using its ethernet port, allowing you to not only gain access to the terminal (and desktop if needed) but to share your laptop’s wifi connection with the Pi directly, using Ubuntu’s standard networking software. This is a very neat solution in comparison to the keyboards, TV’s and routers traditionally used to interface with a Pi.

I’ve attempted to do the same using Windows but gave up after numerous unknown problems. In the end I decided that any “real Pi’er” would want to run Linux on their PC anyway, not only for their reputation but just because they both run the same file-system (making directly modifying the SD card simpler) and you don’t need to bother with finding a third-party SSH client. Ubuntu is simple enough to install alongside Windows so long as you have one free primary partition on your hard-drive and can be done just using at least a 4GB usb flash drive. I prefer to use UNetbootin to create a live usb version of ubuntu, then once this version is running, use ubuntu’s standard installation software (should be an icon on the live desktop) to install it. If you need more help with this there’s plenty of information on-line. Also, be careful! Mistakes here could wipe your whole PC clean!

INGREDIENTS:

  • PC running Ubuntu
  • Ethernet cable
  • Raspberry Pi running Raspbian
  • Micro usb cable to power the Pi
  • Wifi network*

*the network is only required to download a package to identify the Pi’s IP address on the PC, after this no external network is required to communicate with the Pi but may be useful to get further packages on the Pi.

 

Step 1:

First we need to configure Ubuntu to share its connection to the internet with the Raspberry Pi.

  1. Open the “Network connections” window in ubuntu by clicking on the network icon at the top of the desktop and clicking “Edit connections“.
  2. Click the “Add” button and select “Ethernet” as the connection type, then click “Create“.
  3. Change the connection name to whatever you desire.
  4. Click the IPv4 settings tab and using the drop-down menu select “Shared to other computers“.
  5. Click the IPv6 settings tab and using the drop-down menu select “Ignore“.
  6. Click “Save“.

 

Step 2:

Now we need to find the address of the Pi on the local PC network so that we can identify and try to establish an SSH to it. This is the only vital stage that requires an internet connection. If you only have Ethernet access to the internet the Pi doesn’t have to be connected at this point so do the following as you normally would.

  1. Open a terminal window on Ubuntu.
  2. Update the package list; “sudo apt-get update“.
  3. Install arp-scan; “sudo apt-get install arp-scan“.

That’s all! No more configuring on the PC side… Told you Ubuntu’s better…

 

Step 3:

Connect up the Pi!

  1. Connect the Pi to the PC using the ethernet cable.
  2. Don’t forget to insert the Raspbian SD card!
  3. If your PC is capable of outputting a high enough current for the Pi (under 1A, remember that other peripherals in your PC’s usb ports also draw current which adds to this total) then you can also power the Pi from the usb port on your PC. Otherwise or if you’re unsure, use an external power supply as you could damage your PC.

Congratulations, within a few minutes you should see a connection established message telling you the connection works!

 

Step 4:

Now we need to locate the Pi on our network. For this we use arp-scan which we downloaded earlier (or any equivalent program).

  1. Open up a terminal window.
  2. Paste the following command into it, “sudo arp-scan –interface=eth0 –localnet” *
  3. The program should return only one result, note down this IP address (e.g. “10.42.0.66”) as it is how we will identify the Pi on our network. **

*if the program returns a “no such device” message then ensure the Pi is correctly connected or try changing “eth0” to “eth1” etc.

**if more than one result appears then the wrong ethernet port has been scanned, try the same troubleshooting as above.

 

Final step:

Assuming all has gone well we can now connect to the Pi.

  1. Open a terminal window.
  2. Type in “sudo ssh pi@10.42.0.66“, replacing “pi” with your username on the Pi (“pi” is default) and replace the IP address with the one you obtained in the previous step.
  3. You should be prompted for a password, the default one for the pi is “raspberry“.

Now you should be able to use the Pi’s terminal as if you were accessing it though a TV and keyboard. While you can continue to do so without internet access, by connecting your PC to the internet (usually with Wifi) the Pi will be able to access the internet as if it was connected to your router.

NB: After rebooting the PC or the Pi you may not be able to SSH into the Pi any more. Assuming you are not running Ubuntu directly off of the usb flash drive (in which case all data in the Ubuntu system may be lost upon reboot, so repeat the tutorial again) all that has happened is that the Pi’s address has changed. Repeat the previous step again to find it’s new address.

 

Optional:

Although you can use the terminal on the Pi as previously described,you may still wish to view the desktop graphically. This is just a mater of setting up a VNC server on the Raspberry Pi and using the built in VNC viewer on Ubuntu, Remina, to view it. As there are plenty of VNC guides (I recommend using TightVNC) on the web, I won’t repeat it here. Just remember that the address is the one we found earlier using arp-scan!

Leave a Reply

Your email address will not be published. Required fields are marked *