You are not logged in.

#1 2016-09-10 20:06:29

wigywizzle
Member
Registered: 2016-09-10
Posts: 4

[SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

--- [FINAL/ COMBINED SOLUTION] ---

First things first, you need to put Raspbian on your pizero, and set it up as an ethernet device.  Follow these steps to do so: http://blog.gbaman.info?p=791 .

Now we need to be able to ssh into our pi-zero before we can simplify things.

Part I: SSH into your pi, the frustratingly long way:
1) Connect your rpi0 (assuming you already set it up as an ethernet device) to the computer via USB

2) We need to find the name of the device, so run

 sudo dmesg 

you should see some output like this:

.....(other nonsense we don't care about right now).....
[ 1943.306812] usb 1-12: new high-speed USB device number 14 using xhci_hcd
[ 1943.494324] cdc_ether 1-12:1.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-12, CDC Ethernet Device, 2e:2f:d7:3d:10:88
[ 1943.526965] cdc_ether 1-12:1.0 enp0s20f0u12: renamed from usb0
.....(perhaps some more nonsense we don't care about)....

3) We need avahi to assign an IP to the device, so run

 sudo avahi-autoipd -D enp0s20f0u12 

(NOTE: enp0s20f0u12 is the name of my device this time, be sure to replace it with whatever name you see from sudo dmesg)

4) Now we will use avahi to associate the Ip address of the device with the local address raspberrypi.local, so run

 avahi-resolve -n raspberrypi.local 

5) We need to find out what the inet6 address of our device now is, so run

 ip addr 

and note the inet6 address of the device

6) Now we should be able to ssh into our pizero by making use of the ipv6 of the device and the local name we assigned to it, so run

 ssh -6 -o BindAddress=fe80::ccf3:3fff:3ff3:ccc1%enp0s20f0u12 pi@raspberrypi.local 

(NOTE: fe80::cc.........:ccc1 was my inet6 address, and enp0s....u12 is the name of my device this time, be sure to replace them with whatever you saw from your ip addr output!  The default password for pi@raspberrypi.local is "raspberry").

Congratulations, you've just SSH'd into your pi.  But it's a bit irritating to run that huge ssh process every time we want to ssh into the pi, and the pi won't have any internet access to update itself with.  Not to mention that we will have to repeat the entire process whenever we reboot our computer, or unplug the pi.  We can make this a lot more automated and give the pi internet by doing the following:

Part II: Setting up the Pi Zero
1) We need to set up a static ip for the pi, so run:

 sudo nano /etc/network/interfaces 

And change the file to be:

# Start of file (you don't need to include this line)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static

address 10.2.2.3 # any unused IP you want to assign to the RPi
netmask 255.255.255.0
gateway 10.2.2.2 # any IP you want to assign to the ethernet port
network 10.2.2.0
broadcast 10.2.2.255
# End of file (you don't need to include this line)

Now save those changes.

2) We need to set up the nameservers, so run

sudo nano /etc/resolv.conf

and change the file to be:

# Start of file (you don't need to include this line)
nameserver 10.2.2.2
nameserver 8.8.8.8
nameserver 8.8.4.4
# End of file (you don't need to include this line)

3) That's it! Now just reboot your pi for the changes to take effect by running:

sudo reboot

Part III: Seting up forwarding to the pi, all of this should be run from your Arch linux PC
1) First make sure your pi is still the same name as before, and also note the name of the device you intend to share internet from (for me its my ethernet adapter enp3s0) by running:

ifconfig

and checking to see if the device name shows up
2) Lets make sure our device is up by running:

sudo ip link set up dev enp0s20f0u12

(NOTE: make sure to change the enp020f0u12 to your device name)
3) Lets add the IPv4 address for the device by running

sudo ip addr add 10.2.2.2 dev enp0s20f0u12

(NOTE: again the device name...)
4) Lets enable packet forwarding to the device by running

sudo sysctl net.ipv4.ip_forward=1

5) Enable the NAT for the device by running the following 3 commands, making sure to use your device id, and changing enp3s0 to be the ethernet device id that you want to share with your pi!

sudo iptables -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp0s20f0u12 -o enp3s0 -j ACCEPT

6) Lets assign the ip addresses to the Pi zero by running the following 3 commands, making sure to use your device id, and changing enp3s0 to be the ethernet device id that you want to share with your pi!

sudo iptables -I INPUT -p udp --dport 67 -i enp0s20f0u12 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 53 -s 10.2.2.0/24 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 53 -s 10.2.2.0/24 -j ACCEPT

Part IV: Setup a network bridge to the pi so we can effectively share our internet with the pi zero
1) Lets use netctl to create a network bridge by copying the example network bridge file included in the netctl package by running

sudo cp /etc/netctl/examples/bridge /etc/netctl/bridge 
cd /etc/netctl/

2) Lets modify the example network bridge to share internet between our devices, making sure to replace enp3s0 with the device id you want to share internet from and enp0s20f0u12 with the device id of your pi by running

sudo nano bridge

and changing the file to:

# Start of file (you don't need to include this line)

Description="Example Bridge connection"
Interface=br0
Connection=bridge
BindsToInterfaces=(enp3s0 enp0s20f0u12 )
IP=dhcp
## Ignore (R)STP and immediately activate the bridge
#SkipForwardingDelay=yes

# End of file (you don't need to include this line)

Save the changes to the file...

3) Now test the bridge connection using netctl by running:

sudo netctl start bridge

4) Now when we run

ifconfig

we should see our our bridge connection br0 in the output like so:

...
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.104  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::3490:aff:f37f:fdf3  prefixlen 64  scopeid 0x20<link>
        ether 01:20:3f:27:1f:ff  txqueuelen 1000  (Ethernet)
        RX packets 34442  bytes 47881180 (45.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 29738  bytes 4640292 (4.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
...

If you don't see this, something went wrong, so try hunting it down, or if you really can't find it on your own, as a question and be sure to post exactly what you did.  Please don't waste my time without first really  looking into it on your own first (at least spend a few hours debugging on your own...).

5) Let's try ssh'ing into that ipv4 address (inet):

ssh pi@192.168.0.104

Note: replace the 192.168.0.104 with whatever your inet address is.

6) If you can, then your pi now also has whatever internet connection your ehternet device has.  Congrats!  Now to ensure we can ssh into raspberrypi.local instead of having to specify the ip, run:

sudo avahi-resolve -n raspberrypi.local

Note: this may not always be necessary

7) Now we can ssh like normal:

ssh pi@raspberrypi.local

8) Now if you intend on leaving your pizero plugged into the same usb port and want to be able to ssh into it without having to do any setup when you reconnect or reboot, run:

sudo netctl enable bridge

Otherwise, if you intend on reconnecting the same pi device with the same operating system periodically, just run the

sudo netctl start bridge

after you plug your pi into the same USB port that you used for this process, and everything should still be setup for you to ssh like normal.

This isn't the write up I wanted to do, but I'm just swamped with work this month, so I hope it helps you guys out. 

I also wrote my own ambient light controller thats multithreaded and can handle 45fps pixel counting with only a 1% cpu load while sending the results to the pizero via tcp over the USB connection.  If anyone has some interest in seeing how this is done, let me know and I'll write a quick tutorial and open source my code when I get a chance.



---Original Question---

I am attempting to ssh into my rpi0 over USB on Arch Linux.  The pi0 has raspberrian lite, and I was able to easily ssh into it on my macbook.  I've used SSH on my arch distro before but never had this issue before.

Essentially I try to ssh into my pi0 like I successfully do on my macbook:
    $ ssh pi@raspberrypi.local
and it reports back:
    ssh: Could not resolve hostname raspberrypi.local: Name or service not known

Then I looked for the ipv6 to see if I could ssh using the ip address instead:
    $ ip addr
and it reports back:
...
5: enp0s20f0u1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:e3:00:15:cf:c1 brd ff:ff:ff:ff:ff:ff

Now I am sure that 5 is the rpi0, but it doesn't have an IP address.  I was browsing for answers, but they all seemed very unrelated to my problem. 

Does anyone have any experience with this and knows the answer?
---End Original Question ---

---------1st ATTEMPTED SOLUTION (See above for the full solution)-------------
1) Connect your rpi0 (assuming you already set it up as an ethernet device) to the computer
2) Run sudo dmesg to find the name of the device
3) Run sudo avahi-autoipd -D enp0s20f0u12 (enp0s20f0u12 is the name of my device this time)
4) Run avahi-resolve -n raspberrypi.local
5) Run ip addr and note the inet6 address of the device
6) ssh -6 -o BindAddress=fe80::cc09:e8ff:fe63:ccc1%enp0s20f0u12 pi@raspberrypi.local   (fe80::cc.........::ccc1 was my inet6 address, and enp0s....u12 is the name of my device this time)
All will proceed as normal.
I'm sure there is a much easier way to do this, but I'm calling it done for now.  I didn't find much info when trying to solve this problem, so hopefully someone else will find this useful.

-------2ND ATTEMPTED SOLUTION (See above for the full solution) -------
I managed to create an ethernet bridge to the RPi zero over USB, and allow easier ssh'ing using just the bridge's IP address.  This will mean you can easily ssh into your pi reliably, and you will have internet on your RPi zero to update and install software.  Weirdly though, I can use TCP connections between the pizero and the computer only with GoLang, C, and Java, but not with python (all of those as the clients on the main computer, the RPi can run the server in any language).  Anyway, here is exactly what I did to accomplish this (remember never to do sudo commands that you find on the internet unless you know what they do, or are very very desperate and are willing to ruin your computer):
#WHAT WORKED!
#PI stuff:
#I don't know if this helped, but first edit the pi:
PI:sudo nano /etc/network/interfaces
# Change that file to:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static

#just keep those first 3 groups of numbers consistent for these:
address 10.2.2.3 # any unused IP you want to assign to the RPi
netmask 255.255.255.0
gateway 10.2.2.2 # any IP you want to assign to the ethernet port
network 10.2.2.0
broadcast 10.2.2.255

#END File Change
Pi: sudo nano /etc/resolv.conf
# Change the file to:

nameserver 10.2.2.2
nameserver 8.8.8.8
nameserver 8.8.4.4

#End changes

Pi: sudo reboot

#END PI STUFF

#Computer Stuff:
# I don't think this helped...
# Make sure device is up
sudo ip link set up dev enp0s20f0u12
# Add the IPv4 address
sudo ip addr add 10.2.2.2 dev enp0s20f0u12 # arbitrary address

# Temporarily Enable Packet Forwarding
sudo sysctl net.ipv4.ip_forward=1

# Enable NAT
sudo iptables -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp0s20f0u12 -o enp3s0 -j ACCEPT

# Assign Ip addresses to the clients
sudo iptables -I INPUT -p udp --dport 67 -i enp0s20f0u12 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 53 -s 10.2.2.0/24 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 53 -s 10.2.2.0/24 -j ACCEPT
# END of not helping

# THIS HELPED: Setup a network bridge!
sudo cp /etc/netctl/examples/bridge /etc/netctl/bridge
cd /etc/netctl/
sudo nano bridge
# edit that bridge file to be:

Description="Example Bridge connection"
Interface=br0
Connection=bridge
BindsToInterfaces=(enp3s0 enp0s20f0u12 )
IP=dhcp
## Ignore (R)STP and immediately activate the bridge
#SkipForwardingDelay=yes

# END editing the file

#Test the bridge
sudo netctl start bridge

# Now your pizero is IPv4:  192.168.0.103
# we can ssh pi@192.168.0.103 successfully
# your pi has internet!
# all is good.

# To have this be done on startup automatically:
sudo netctl enable bridge # creates a systemd service to start on boot
# If you make any changes to bridge, you need to reenable:
sudo netctl reenable bridge # re-enable the profile



I don't have the time to do a nice write-up right now, so I'm just going to post that.  I'll try to come back and make it more newbie friendly when I get a chance.

Last edited by wigywizzle (2016-10-01 19:32:45)

Offline

#2 2016-09-10 23:44:31

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,443
Website

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

edit
Sorry for incorrectly closing this. I didn't read carefully and thought that it was asking for support for Arch Linux ARM.

Reopening...

Last edited by Xyne (2016-09-11 23:11:17)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2016-09-16 19:46:23

wigywizzle
Member
Registered: 2016-09-10
Posts: 4

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

UPDATE:
Still have yet to figure out the solution.  I ran sudo dmesg and got this important line:
[ 1943.306812] usb 1-12: new high-speed USB device number 14 using xhci_hcd
[ 1943.494324] cdc_ether 1-12:1.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-12, CDC Ethernet Device, 2e:20:47:4d:10:88
[ 1943.526965] cdc_ether 1-12:1.0 enp0s20f0u12: renamed from usb0

So now I can be certain the enp0s..... ethernet device is the raspberry Pi zero that's just been reassigned from usb to ethernet, since I do have it set up as an ethernet gadget. 

I tried numerous methods of getting this thing to work since then, and most recently I tried:
sudo avahi-autoipd enp0s20f0u12i1

which returned:
Found user 'avahi' (UID 84) and group 'avahi' (GID 84).
Successfully called chroot().
Successfully dropped root privileges.
Starting with address 169.254.5.246
Callout BIND, address 169.254.5.246 on interface enp0s20f0u12i1
client: RTNETLINK answers: Numerical result out of range
Script execution failed with return value 2
Successfully claimed IP address 169.254.5.246
^CGot SIGINT, quitting.
Callout STOP, address 169.254.5.246 on interface enp0s20f0u12i1
Killing child.
Killing child.
Killing child.
Killing child.
Killing child.
Killing child.
Killing child.
Killing child.
client: RTNETLINK answers: No such process
client: RTNETLINK answers: Numerical result out of range
Script execution failed with return value 2


But that didn't help so I went about trying other things... then from a tutorial I tried:
avahi-resolve -n raspberrypi.local

which printed to terminal:
raspberrypi.local       fe80::122e:25a4:82c2:936b

then:
avahi-browse -alr

printed:
+ enp0s20f0u12i1 IPv6 raspberrypi [ba:5a:fd:0c:a1:d4]               Workstation          local
= enp0s20f0u12i1 IPv6 raspberrypi [ba:5a:fd:0c:a1:d4]               Workstation          local
   hostname = [raspberrypi.local]
   address = [fe80::122e:25a4:82c2:936b]
   port = [9]
   txt = []

Still no IP!

Very very frustrating.  I've been through the wiki's and tried most of what I can think of, but I'm at my wits end.

Last edited by wigywizzle (2016-09-16 19:47:07)

Offline

#4 2016-09-16 21:26:09

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,850

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

The thing that confuses me is that you said you want to do this over USB.  Is the RasPi presenting itself as a NET interface over the USB?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2016-09-20 15:58:31

wigywizzle
Member
Registered: 2016-09-10
Posts: 4

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

Sorry for the delay, I've been quite busy with other projects.

ewaller - Sort of, the RPi is an RPi Zero, for which there are many tutorials that show how to turn it into an Ethernet gadget over a USB connection to allow a headless install over USB (perhaps the most straightforward tutorial: http://blog.gbaman.info?p=791).  I find it easiest to think of it as the following:
1) The RPi (which is representing itself as an Ethernet device) connects via USB, 
2) Arch detects that it is a USB-Ethernet gadget, and reassigns it as an Ethernet device,
3) The RPi is stripped of its USB id (USB-0 in this case) and is assigned an Ethernet Device ID of enp0s20f0u12 (however it can be different depending on your computer and which USB port you plug it into). 

All of this is being shown in the dmesg output that I posted shortly after plugging in the RPi.

What still confuses me:
Normally, I can just connect to the RPi through ssh pi@raspberrypi.local, then just add the SHA key to known hosts when prompted.  However, Arch won't let me do that.  Instead, I have to use avahi to auto assign an IP address (which shouldn't be necessary, since the Pi DOES display its own ipV6 address), then I have to use avahi to resolve the host name raspberrypi.local (which also shouldn't be necessary, since this is a preset host name of the RPi), and even then I still have to include the original ipv6 (not the avahit generated ip) and the device ID just to ssh into the raspberry pi.  Only then do I get to add the SHA key to known hosts, otherwise my connection will either be refused, or the hostname can't be resolved.  I initially thought that I should just manually add an IPv4 address to the RPi, and then ssh directly to that address or the hostname, but that failed miserably.  I've tried manually assigning IP's to the RPi then using avahi to resolve the hostname, but that doesn't work either.  It seems as though if I don't follow that exact process, I can't ssh into the pi, which is the first time I've ever run into such a problem on Arch.  Usually, there are multiple ways to accomplish the same task on arch, and almost always a manual way (like manually assigning an IP address instead of using Avahi). 

My new problem:
I need to set up my pi as a local server, and my pc as a client for that server.  I have a good deal of networking experience, and was easily able to get this done using my macbook pro and the RPiZero, but I need to now get it working on Arch (my main computer).  I manage to ssh into the Pi to get the python server running, but when I go to set up the python TCP client, I get the message
" Traceback (most recent call last):
  File "pyClient.py", line 14, in <module>
    s.bind((TCP_IP, TCP_PORT))
OSError: [Errno 99] Cannot assign requested address "
Which is very odd.  After ensuring everything was still correct in my python script, I wondered if it was an issue with my python version.  Rather than mess with different versions of python, I rewrote the client and server in 3 different languages (Java, Golang and C... it wasn't much code anyway).  Unfortunately, while the server on the Pi still worked, the client on my computer was unable to make a connection to it.  My new suspicion is that since I had internet sharing to the pizero from my macbook pro, maybe I need to allow the pizero an internet connection in order to establish a TCP connection with it (although this doesn't make any sort of sense, since I've set up numerous local network tcp connections before, although none have been over a USB). 

This is actually all part of a simple (or I thought it'd be simple) ambient lighting project, which has my computer (the client) take screenshots of different portions of the screen, then average the pixel colors for each section and send those color values to the RPi-zero which I use to control an individually addressable LED Strip to create a matching light behind each section of the monitor.  There are plenty of Arduino tutorials for the project, but should I figure everything out, I will write a tutorial using the Raspberry Pi Zero and arch Linux.  Why wouldn't I just give up and buy a Arduino? Well I picked up 15 Pi-Zero's for $1 a piece the other day, and I'm a broke senior college student, so an Arduino is a bit out of my price range right now (altogether the project will only cost $13 to put together for a $1 PiZero, $10 Light Strip, and $2 in USB cords).

I placed this under the newbie section, but on second thought I'm not really a newbie (arch user for 2 years and linux user for 6 years) and this isn't exactly a newbie problem.  I've worked with ssh before, and have done this exact same process on multiple other linux distros, but for some reason, arch is a beast and a pleasure of its own. 

If anyone has any sort of advice or can enlighten us with some Arch-specific explanation as to why things are behaving the way they are, I'd really appreciate it. 

I need to brush up on this forum's specific rules, but if its not violating any, could we leave this thread open for a month or two just in case someone comes up with something?

I mostly solved this with the improved solution in my first post.  I'll do my best to go back and clean it up.  Still would be nice to hear any other ideas from more experienced arch users.

Last edited by wigywizzle (2016-09-20 19:08:57)

Offline

#6 2016-09-29 03:12:35

flammenwurfer
Member
Registered: 2009-02-04
Posts: 118

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

So I am trying to do the same thing and it's weird.  I  can ping the pi zero with "ping raspberrypi" and it gives me 127.0.1.1 as the ip address.  If I try to ssh to it with "ssh pi@raspberrypi.local" or "ssh pi@127.0.1.1" it fails.

This is what I'm getting from avahi:

+   usb0 IPv6 raspberrypi [9e:07:9b:0c:08:32]               Workstation          local
=   usb0 IPv6 raspberrypi [9e:07:9b:0c:08:32]               Workstation          local
   hostname = [raspberrypi.local]
   address = [fe80::a66c:2232:7ba8:870b]
   port = [9]
   txt = []
+   usb0 IPv4 raspberrypi [9e:07:9b:0c:08:32]               Workstation          local
=   usb0 IPv4 raspberrypi [9e:07:9b:0c:08:32]               Workstation          local
   hostname = [raspberrypi.local]
   address = [169.254.5.143]
   port = [9]
   txt = []

Offline

#7 2016-10-01 18:27:08

wigywizzle
Member
Registered: 2016-09-10
Posts: 4

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

127.0.1.1 is the pi's local address, it will not be accessible, so don't bother trying to ssh into it.  You should be getting the ip address of the bridge connection when you ping your pi from the host computer.
Seems like that's the output of using avahi on your pi.   Are you using avahi on your pi or your arch linux PC? 

I've done my steps on 2 separate Arch linux setups that I have, and it worked both times.  I've gone back and updated my solution to be much clearer and more user friendly.  Try following my updated version closely, if you don't understand something feel free to ask, or if it doesn't work, then post the commands exactly as you ran them, the avahi output from your PC, the ifconfig output from your PC, and the ip addr or ifconfig output from your pi, and I'll take a look to try and help you out when I get some free time.

Last edited by wigywizzle (2016-10-01 19:40:53)

Offline

#8 2017-01-13 18:52:47

XN3B3NX
Member
Registered: 2017-01-13
Posts: 2

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

Not working for me.

[l33n@XN3B3NX ~]$ avahi-resolve -n raspberrypi.local
raspberrypi.local	fe80::1249:4346:4db0:2440
[l33n@XN3B3NX ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 54:ab:3a:63:15:ad brd ff:ff:ff:ff:ff:ff
3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 58:91:cf:cc:6f:ff brd ff:ff:ff:ff:ff:ff
    inet 192.168.69.17/24 brd 192.168.69.255 scope global dynamic wlp4s0
       valid_lft 343748sec preferred_lft 343748sec
    inet6 fe80::5110:a72c:ab37:593f/64 scope link 
       valid_lft forever preferred_lft forever
7: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
    link/none 
    inet 10.0.10.6 peer 10.0.10.5/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::5283:75:58a9:129d/64 scope link flags 800 
       valid_lft forever preferred_lft forever
9: enp0s20u1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:e9:96:23:5f:0f brd ff:ff:ff:ff:ff:ff
    inet 169.254.5.70/16 brd 169.254.255.255 scope link enp0s20u1:avahi
       valid_lft forever preferred_lft forever
    inet6 fe80::50e9:96ff:fe23:5f0f/64 scope link 
       valid_lft forever preferred_lft forever
[l33n@XN3B3NX ~]$ ssh -6 -o BindAddress=fe80::50e9:96ff:fe23:5f0f%enp0s20u1 pi@raspberrypi.local
ssh: Could not resolve hostname raspberrypi.local: Name or service not known

Last edited by XN3B3NX (2017-01-14 14:48:19)

Offline

#9 2017-01-14 12:50:46

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,443
Website

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

This thread is severely lacking code tags.

Start using them.

@wigywizzle
Thanks for posting the results of your work (which I have just seen now). Please create a page on our wiki (if it doens't yet exist) and transfer your guide to it. It is a much more appropriate place for a full guide and the page can be maintained indefinitely as opposed to a thread which is prone to rot over time.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#10 2017-01-17 15:16:36

XN3B3NX
Member
Registered: 2017-01-13
Posts: 2

Re: [SOLVED] Trying to SSH into rpi0 over USB on Arch Linux

I am unable to set up the bridge interface.

Also, I can SSH into the raspberry pi zero, but not by following your directions.

I run

sudo avahi-autoipd -D enp0s20u1

And then:

avahi-resolve -n raspberrypi.local

And the terminal spits this out:

raspberrypi.local	fe80::54ac:2b71:fc8c:d065

At this point, in order to SSH into the raspberry pi zero, I have to run this:

ssh -6 -o BindAddress=fe80::ec24:ffcd:7d00:f6d%enp0s20u1 pi@fe80::54ac:2b71:fc8c:d065

Actually, that did not even work this time, let me show you the entire terminal log and what I had to do that finally worked in the end. The inet6 address seems to change what seems to be randomly and I have to check ip addr to make sure it has not changed:

[l33n@XN3B3NX ~]$ cat pi
sudo ip link set up dev enp0s20u1
sudo ip addr add 10.2.2.2 dev enp0s20u1
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp0s20u1 -o wlp4s0 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 67 -i enp0s20u1 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 53 -s 10.2.2.0/24 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 53 -s 10.2.2.0/24 -j ACCEPT

sudo avahi-autoipd -D enp0s20u1
avahi-resolve -n raspberrypi.local

ssh -6 -o BindAddress=fe80::885:da30:9a24:20f6%enp0s20u1 pi@fe80::6b4f:3a7:10c8:3daf
[l33n@XN3B3NX ~]$ sudo avahi-autoipd -D enp0s20u1
[l33n@XN3B3NX ~]$ avahi-resolve -n raspberrypi.local
raspberrypi.local	fe80::54ac:2b71:fc8c:d065
[l33n@XN3B3NX ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
3: enp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 54:ab:3a:63:15:ad brd ff:ff:ff:ff:ff:ff
4: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 58:91:cf:cc:6f:ff brd ff:ff:ff:ff:ff:ff
    inet 192.168.69.17/24 brd 192.168.69.255 scope global dynamic wlp4s0
       valid_lft 359913sec preferred_lft 359913sec
    inet6 fe80::5110:a72c:ab37:593f/64 scope link 
       valid_lft forever preferred_lft forever
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
    link/none 
    inet 10.37.10.6 peer 10.37.10.5/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::b464:671f:7de9:c0b7/64 scope link flags 800 
       valid_lft forever preferred_lft forever
6: enp0s20u1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 5a:78:e3:f5:ae:43 brd ff:ff:ff:ff:ff:ff
    inet 169.254.10.37/16 brd 169.254.255.255 scope link enp0s20u1:avahi
       valid_lft forever preferred_lft forever
    inet6 fe80::ec24:ffcd:7d00:f6d/64 scope link 
       valid_lft forever preferred_lft forever
[l33n@XN3B3NX ~]$ vim pi
[l33n@XN3B3NX ~]$ vim pi
[l33n@XN3B3NX ~]$ vim pi
[l33n@XN3B3NX ~]$ cat pi
sudo ip link set up dev enp0s20u1
sudo ip addr add 10.2.2.2 dev enp0s20u1
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp0s20u1 -o wlp4s0 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 67 -i enp0s20u1 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 53 -s 10.2.2.0/24 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 53 -s 10.2.2.0/24 -j ACCEPT

sudo avahi-autoipd -D enp0s20u1
avahi-resolve -n raspberrypi.local

ssh -6 -o BindAddress=fe80::ec24:ffcd:7d00:f6d%enp0s20u1 pi@fe80::54ac:2b71:fc8c:d065
[l33n@XN3B3NX ~]$ ssh -6 -o BindAddress=fe80::ec24:ffcd:7d00:f6d%enp0s20u1 pi@fe80::54ac:2b71:fc8c:d065
bind: fe80::ec24:ffcd:7d00:f6d%enp0s20u1: Cannot assign requested address
ssh: connect to host fe80::54ac:2b71:fc8c:d065 port 22: Cannot assign requested address
[l33n@XN3B3NX ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
3: enp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 54:ab:3a:63:15:ad brd ff:ff:ff:ff:ff:ff
4: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 58:91:cf:cc:6f:ff brd ff:ff:ff:ff:ff:ff
    inet 192.168.69.17/24 brd 192.168.69.255 scope global dynamic wlp4s0
       valid_lft 359438sec preferred_lft 359438sec
    inet6 fe80::5110:a72c:ab37:593f/64 scope link 
       valid_lft forever preferred_lft forever
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
    link/none 
    inet 10.37.10.6 peer 10.37.10.5/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::b464:671f:7de9:c0b7/64 scope link flags 800 
       valid_lft forever preferred_lft forever
6: enp0s20u1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 5a:78:e3:f5:ae:43 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::ec24:ffcd:7d00:f6d/64 scope link 
       valid_lft forever preferred_lft forever
[l33n@XN3B3NX ~]$ ssh -6 -o BindAddress=fe80::ec24:ffcd:7d00:f6d%enp0s20u1 pi@fe80::54ac:2b71:fc8c:d065
The authenticity of host 'fe80::54ac:2b71:fc8c:d065 (fe80::54ac:2b71:fc8c:d065)' can't be established.
ECDSA key fingerprint is SHA256:RNsCno2c4CXJ9kg7JWkTPfLv1F8xfSEoVMtyhhG8hIc.
Are you sure you want to continue connecting (yes/no)? 

In any event, I cannot use pi@raspberry.local. That never works. I have to the inet6 address that the terminal spits out when I run avahi-resolve -n raspberrypi.local...

Now, I followed your tutorial once I was finally able to SSH into the pi. I updated /etc/network/interfaces and /etc/resolv.conf and rebooted the pi.

Then, on arch, I ran these commands:

sudo ip link set up dev enp0s20u1
sudo ip addr add 10.2.2.2 dev enp0s20u1
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp0s20u1 -o wlp4s0 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 67 -i enp0s20u1 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 53 -s 10.2.2.0/24 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 53 -s 10.2.2.0/24 -j ACCEPT

I updated /etc/netctl/bridge on arch so that it looks like this:

# Start of file (you don't need to include this line)
Description="Example Bridge connection"
Interface=br0
Connection=bridge
BindsToInterfaces=(wlp4s0 enp0s20u1)
IP=dhcp
## Ignore (R)STP and immediately activate the bridge
#SkipForwardingDelay=yes
# End of file (you don't need to include this line)

Now, I try to do sudo netctl start bridge, and this is the output, including the log with corresponding errors:

[l33n@XN3B3NX ~]$ sudo netctl start bridge
Job for netctl@bridge.service failed because the control process exited with error code.
See "systemctl status netctl@bridge.service" and "journalctl -xe" for details.
[l33n@XN3B3NX ~]$ systemctl status netctl@bridge.service
● netctl@bridge.service - Networking for netctl profile bridge
   Loaded: loaded (/usr/lib/systemd/system/netctl@.service; static; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2017-01-17 10:09:59 CST; 19s ago
     Docs: man:netctl.profile(5)
  Process: 1892 ExecStart=/usr/lib/network/network start %I (code=exited, status=1/FAILURE)
 Main PID: 1892 (code=exited, status=1/FAILURE)

Jan 17 10:09:29 XN3B3NX dhcpcd[1917]: DUID 00:01:00:01:1f:1a:d0:be:58:91:cf:cc:6f:ff
Jan 17 10:09:29 XN3B3NX dhcpcd[1917]: br0: IAID a8:02:cb:ad
Jan 17 10:09:29 XN3B3NX dhcpcd[1917]: br0: soliciting a DHCP lease
Jan 17 10:09:59 XN3B3NX dhcpcd[1917]: timed out
Jan 17 10:09:59 XN3B3NX network[1892]: DHCP IPv4 lease attempt failed on interface 'br0'
Jan 17 10:09:59 XN3B3NX network[1892]: Failed to bring the network up for profile 'bridge'
Jan 17 10:09:59 XN3B3NX systemd[1]: netctl@bridge.service: Main process exited, code=exited, status=1/FAILURE
Jan 17 10:09:59 XN3B3NX systemd[1]: Failed to start Networking for netctl profile bridge.
Jan 17 10:09:59 XN3B3NX systemd[1]: netctl@bridge.service: Unit entered failed state.
Jan 17 10:09:59 XN3B3NX systemd[1]: netctl@bridge.service: Failed with result 'exit-code'.

In any event, this is the output of ip addr:

[l33n@XN3B3NX ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
3: enp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 54:ab:3a:63:15:ad brd ff:ff:ff:ff:ff:ff
4: wlp4s0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 58:91:cf:cc:6f:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5110:a72c:ab37:593f/64 scope link 
       valid_lft forever preferred_lft forever
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
    link/none 
    inet 10.37.10.6 peer 10.37.10.5/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::b464:671f:7de9:c0b7/64 scope link flags 800 
       valid_lft forever preferred_lft forever
7: enp0s20u1: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether a6:c2:a8:02:cb:ad brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a4c2:a8ff:fe02:cbad/64 scope link 
       valid_lft forever preferred_lft forever
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether a6:c2:a8:02:cb:ad brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a4c2:a8ff:fe02:cbad/64 scope link 
       valid_lft forever preferred_lft forever

As you can see, there is only a inet6 address here for the br0 interface. When I try to run ssh pi@fe80::a4c2:a8ff:fe02:cbad, this is what I get:

[l33n@XN3B3NX ~]$ ssh pi@fe80::a4c2:a8ff:fe02:cbad
ssh: connect to host fe80::a4c2:a8ff:fe02:cbad port 22: Invalid argument

Would really appreciate your help on this. Thanks in advance.

Last edited by XN3B3NX (2017-01-17 15:18:26)

Offline

Board footer

Powered by FluxBB