Raspberry pi and the OTG internet nightmare with debian 8 (solved)

So I’ve recently got back into some raspberry pi dev, Since ive been away the raspberry pi zero is readily available so more and more people are using them. I’ve seen a few people SSHing into there pi zero’s with just one USB cable going from their laptop to their OTG port on the pi zero, I wanted a piece of the pie so I looked into it.

It’s quite simple since a lot of the hackery has been put into the raspberry pi kernel so all you need to do it change a few things in a few files and your all set.

The setup

First things first, Get a fresh raspbian image and make sure its up to date. Next you will need to take the micro SD card and put it into your laptop with a card reader. You will be working in the Boot directory so point your file manager or your terminal to it.

config.txt

The first file you are looking for is called “config.txt”. So open up this file with your favourite text editor, You will want to add this line to the end of the file


dtoverlay=dwc2

Save it and close the text editor

cmdline.txt

The next file you will need to edit is called “cmdline.txt”. So again open up this file with your favourite text editor, Now this is a little different because you will need to add some code but it needs to added after the word “rootwait”


modules-load=dwc2,g_ether

Once this is done also save and close the text editor.
Dont forget to add a file call “ssh” in the boot directory but leave that file blank.

Now you can pop your SD card back into the raspberry pi and connect it to your debian machine via a USB cable to the OTG port on your pi zero. You many need to wait about a minute before trying to connect to the pi zero just to give it some time to boot up. This is where I got stuck.

IPV6

I’ve heard of IPV6 be never used it myself, As I said this is where I got lost looking for a solution. So you will need to install some software on your debian machine but this is the only catch


sudo apt-get install avahi-daemon avahi-discover libnss-mdns
sudo apt-get install avahi-daemon

After that has install you will need to open up “Avahi Zeroconf Browser” from your menu bar on debian. There should be a few heading but the one you need is called “usb0 ipv6” this is where you will find the ipv6 ip address for your raspberry pi

As you can see its a little different from the ipv4 address you are normally used to seeing. You will only need the part that I have highlighted in the picture above, You dont need the “:9” on the end

Now its time to ssh into the pi, You will need to use the command posted below but you will need to add your own ipv6 ip address in there. The “%usb0” part tells the ssh client that you are using usb instead of wifi or ethernet


ssh -6 fe80::e435:a05:4c30:220d%usb0 -l pi

It will tell you the “ECDSA key fingerprint” has changed and do you want to continue so just type yes then it will ask for your password of the raspberry pi then you should be in.

SCP

If like me you sometimes need to move files over SSH and use SCP then read on. This took a little bit of searching round to find but I knew it had something to do with IPV6. normally if you want to use scp you would do something like this


scp file.py pi@192.168.x.x:/home/pi

But again its different because we are using IPV6 and doing it over a USB cable. So all you need to do is copy the line from below but again replace the IPV6 ip address with your own pi zero one.


scp -6 file.py pi@[fe80::ec8b:6587:9010:70bf%usb0]:/home/pi

Hope this was a help because It took me a good part of a week to work out myself

Happy hacking

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s