Nander
Posts: 31
Joined: Tue Dec 04, 2012 11:21 pm
Location: The Hague - Netherlands

Ssh over bluetooth

Tue Mar 12, 2013 1:31 pm

I've been looking for this for ages but couldn't find it anywhere.
I got the bluez package running and paired with my phone but I would like to be able to do ssh over this connection.
I know wifi is an option but I tried with two wifi adapters: one for command and control and the other to connect to a network but as soon as you do that it kicks you off the command an control network.
So my question is: how could one go about and do ssh over bluetooth orrr... have hostapd running and be connected to a wifi network at the same time?

Spid
Posts: 525
Joined: Sat Jan 19, 2013 12:47 pm

Re: Ssh over bluetooth

Tue Mar 12, 2013 2:03 pm

You need Bluetooth PAN (Networking) installed on both devices http://en.wikipedia.org/wiki/Personal_area_network

sudo apt-get install bluez-tools
sudo apt-get install bluez-utils
sudo apt-get install blueman

the last entry is a GUI for Bluez

This is slightly out-of-date but the basics are OK http://elinux.org/Bluetooth_Network

http://www.howtoforge.com/

http://www.penguintutor.com/blog/viewblog.php?blog=6392
I will always assume you are running Raspbian for desktop and Raspbmc for XMBC !

shaun39
Posts: 1
Joined: Sun Jun 02, 2013 4:25 am

Re: Ssh over bluetooth

Sun Jun 02, 2013 4:26 am

Hi Nander,

Did you ever get this working?

User avatar
Nastanir
Posts: 41
Joined: Tue Dec 24, 2013 3:16 pm
Location: IIT Guwahati, India
Contact: Website

Re: Ssh over bluetooth

Mon Dec 30, 2013 7:02 am

I am going to try the method soon. The problem faced by author of first post is a problem for me as well. Just another quick question: Is the bluetooth speed is good enough for ssh to command line?

User avatar
Nastanir
Posts: 41
Joined: Tue Dec 24, 2013 3:16 pm
Location: IIT Guwahati, India
Contact: Website

Re: Ssh over bluetooth

Mon Dec 30, 2013 2:35 pm

A problem cropped up even before attempting. Any one knows a ssh client which works over bluetooth? in iOS or Windows Phone 8.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22741
Joined: Sat Jul 30, 2011 7:41 pm

Re: Ssh over bluetooth

Mon Dec 30, 2013 2:40 pm

I would expect that the bluetooth connection would just appear as a network connection - so you simply have another IP address on the network, with the transport layer underneath being bluetooth rather than ethernet/TCP/IP

I could be wrong.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Mon Dec 30, 2013 4:57 pm

jamesh wrote:I would expect that the bluetooth connection would just appear as a network connection
I'm not so sure... there's a topic here regarding using bluetooth for internet sharing, but 1) It's Android specific, and 2) It relies on newer Android versions that have support for Internet Sharing over Bluetooth, which I gather is not the same as simply connecting to a local network via IP address. I'll give it a try tonight with VX ConnectBot, my Android SSH client-of-choice. Technically I would think it's possible using the rfcomm profile, but might need some programming on the client, which is beyond me.

User avatar
DougieLawson
Posts: 35381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Ssh over bluetooth

Mon Dec 30, 2013 5:12 pm

Are you running bnep? You need that (on both ends) to encapsulate ethernet within bluetooth.

http://blog.kugelfish.com/2012/10/look- ... tooth.html
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Mon Dec 30, 2013 5:26 pm

DougieLawson wrote:Are you running bnep? You need that (on both ends) to encapsulate ethernet within bluetooth.

http://blog.kugelfish.com/2012/10/look- ... tooth.html
Yes, have successfully created the bnep devices on both ends, and bridged the Pi-side bnep0 device to the Pi's eth0 or wlan0 device for internet access (tethering).

By the way, the pand daemon mentioned in that link has been deprecated under BlueZ for some time and (typically), the replacement service (NAP) is not well documented...

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Tue Dec 31, 2013 3:05 am

Well, whaddaya know. I was able to simply SSH to my Pi via Bluetooth using the Android VX ConnectBot client (on a Nexus 4 running KitKat 4.4.2). The Pi was acting as a Bluetooth Network Access Point, ala some scripts I hacked together that are available at https://github.com/Douglas6/pinaple. Something similar (but better) is available from ykasidit at https://github.com/ykasidit/ecodroidlink. See the full story on this topic.

I couldn't access any other IPs on the local network. I know squat about networking, so this may well be surmountable.

I know, I know, it's not real if it's not on YouTube, but all I have is this screen shot:

Image

User avatar
DougieLawson
Posts: 35381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Ssh over bluetooth

Tue Dec 31, 2013 11:18 am

Douglas6 wrote:I couldn't access any other IPs on the local network. I know squat about networking, so this may well be surmountable.
If you can connect to your RPi and the RPi is connected to the outside world via your gateway/router then with a bit of bridging between connections you can route traffic from one interface to another.

That's the technique that RPi access points use, so you can crib the instructions from the "Make my RPi an access point" docs that are out on the internets.

BTW, I use JuiceSSH on my android tablet to access my RPi (and other systems).
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Tue Dec 31, 2013 2:26 pm

Yeah, BT is different.

User avatar
DougieLawson
Posts: 35381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Ssh over bluetooth

Tue Dec 31, 2013 3:58 pm

Douglas6 wrote:Yeah, BT is different.
Is it? What shows up from ifconfig -a?
Have you tried bridging the BT interface to the eth0?
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Tue Dec 31, 2013 7:32 pm

Yeah, it's odd. From the phone, I can ping the Pi serving as the NAP, I can ping http://www.google.com, but I can't reach other LAN devices, which I can reach from the NAP server directly.

Code: Select all

$ ifconfig -a
bnep0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet6 addr: fe80::202:72ff:fedd:bb3b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:839 errors:0 dropped:0 overruns:0 frame:0
          TX packets:933 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:141226 (137.9 KiB)  TX bytes:384122 (375.1 KiB)

br0       Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.80  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:feed:9452/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3569 errors:0 dropped:0 overruns:0 frame:0
          TX packets:423 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:418493 (408.6 KiB)  TX bytes:47708 (46.5 KiB)

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10046 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4300 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3163742 (3.0 MiB)  TX bytes:649478 (634.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Code: Select all

$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.000272ddbb3b       no              bnep0
                                                        eth0
IP forwarding is enabled. Same results whether STP is enabled or no.

User avatar
DougieLawson
Posts: 35381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Ssh over bluetooth

Tue Dec 31, 2013 8:24 pm

What does the IPv4 routing table look like?

Can you see the routing table on the connected BT device? Or is it hidden from view?
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

HashNinja
Posts: 27
Joined: Fri Dec 27, 2013 4:30 am

Re: Ssh over bluetooth

Wed Jan 01, 2014 10:30 pm

Douglas6 wrote:Well, whaddaya know. I was able to simply SSH to my Pi via Bluetooth using the Android VX ConnectBot client (on a Nexus 4 running KitKat 4.4.2). The Pi was acting as a Bluetooth Network Access Point, ala some scripts I hacked together that are available at https://github.com/Douglas6/pinaple. Something similar (but better) is available from ykasidit at https://github.com/ykasidit/ecodroidlink. See the full story on this topic.

I couldn't access any other IPs on the local network. I know squat about networking, so this may well be surmountable.

I know, I know, it's not real if it's not on YouTube, but all I have is this screen shot:

Image
Hey Douglas, just wondering, when you ssh to your pi via bluetooth, did either your android phone or pi have internet connection? I have been reading about PAN and I havent found a solid answer to whether or not you can ssh via bluetooth without any internet connection on either device. Thanks

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Thu Jan 02, 2014 2:08 am

HashNinja wrote:Hey Douglas, just wondering, when you ssh to your pi via bluetooth, did either your android phone or pi have internet connection? I have been reading about PAN and I havent found a solid answer to whether or not you can ssh via bluetooth without any internet connection on either device. Thanks
In that test the phone definitely did not have Internet, both mobile data and Wifi were turned off. In fact it seems like my phone (Nexus 4) will not connect over Bluetooth if Wifi is available. The Pi was connected to the router, connected to the Internet. You wouldn't think that would matter; but it might, since the point of the phone's BT network connection is Internet sharing. I'll give it a try when I can with the Ethernet on the Pi yanked as well.

HashNinja
Posts: 27
Joined: Fri Dec 27, 2013 4:30 am

Re: Ssh over bluetooth

Thu Jan 02, 2014 5:17 pm

Alright thanks. I gave up trying to get my pi to ssh over bluetooth but I may give it another try since you were able to.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Thu Jan 02, 2014 6:21 pm

Nota Bene: the Pi needs to be on a network, and have an IP address for this NAP service solution, it won't do ad-hoc. That might be possible in the Bluetooth spec with the GN (Group ad hoc Network) service. Hmmm...something else to try. Not having root access on the phone is limiting, sigh.

So many projects, so little gray matter.

HashNinja
Posts: 27
Joined: Fri Dec 27, 2013 4:30 am

Re: Ssh over bluetooth

Fri Jan 03, 2014 4:24 pm

Oh ok. Thanks Douglas for the clarification. Just wondering, could you post your /etc/network/interfaces that you used to bridge the bluetooth and eth0. I cant seem to get mine to work. And also, does my android phone require tethering option from the provider? MY phone is rooted btw.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Fri Jan 03, 2014 4:54 pm

No, the provider tethering option doesn't apply, that's for using your phone data as the internet source, this is the other 'way round.

I won't get to my Pi before tonight, but I think this is right (from the README at https://github.com/Douglas6/pinaple)

Code: Select all

auto lo
iface lo inet loopback

auto br0
iface br0 inet dhcp
    bridge-ports eth0
    bridge_fd 5
Do not assign an IP to the eth0 device, just the bridge (br0). You'll need to pair and trust the device, and start the BlueZ NAP service. You can use EcoDroidLink, my pinaple scripts (link above), or follow these instructions

HashNinja
Posts: 27
Joined: Fri Dec 27, 2013 4:30 am

Re: Ssh over bluetooth

Fri Jan 03, 2014 8:44 pm

Thanks man. The problem was the static ip I assigned to my eth0. But now I have ran into another problem and I cant find a solution. When I try running the test-nap.py script, I get

Code: Select all

File "test-nap.py", line 9, in <module>
    import bluezutils
ImportError: No module named bluezutils
but I already have bluezutils. I tried sudo apt-get upgrade bluezutils, but its at latest version. Btw I am using this http://www.hkepc.com/forum/viewthread.php?tid=1710030 tutorial that you linked.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Fri Jan 03, 2014 9:27 pm

DId you get that test-nap.py from the Github? I believe that's been updated for BlueZ 5, which is where the bluezutils python package comes from, I think. (The Raspian repo only has BlueZ 4.99)

'Howdy's' tutorial has a somewhat different version of test-nap.py that does not use bluezutils. It's quoted on that link; give it a try.

HashNinja
Posts: 27
Joined: Fri Dec 27, 2013 4:30 am

Re: Ssh over bluetooth

Sat Jan 04, 2014 1:08 am

Hey Douglas. So I decided to restart fresh and use your github files. After copying over all the files, making them executable, and moving them to the specified destination, I tried running sudo pinaple-agent --pin 1234 and I also tried sudo pinaple-agent but I keep getting error

Code: Select all

Making Bluetooth adapter discoverable
Traceback (most recent call last):
  File "pinaple-agent", line 60, in <module>
    adapter.RegisterAgent(agent_path, "KeyboardDisplay")
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists
Not sure why this is showing up.
Also, I tried running pinaple and it gives me error

Code: Select all

 File "pinaple", line 16
    PIDFILE=/var/run/$DAEMON_NAME.pid
            ^        ^
SyntaxError: invalid syntax
Thanks

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Ssh over bluetooth

Sat Jan 04, 2014 2:29 am

Ok, two problems:
HashNinja wrote:I also tried sudo pinaple-agent but I keep getting error

Code: Select all

dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists
There can be just one Bluetooth 'agent' running at a time. This error indicates that there is already an agent running. I'm guessing you're running the X desktop? That starts It's own BT agent, Blueman, which is conflicting with pinaple-agent.
There's nothing terribly special about pinaple-agent, you can go ahead and use the desktop app to pair and trust your device. It must be trusted to accept network connections. Pinaple-agent is intended for headless systems that don't otherwise have a BT agent.
HashNinja wrote:Also, I tried running pinaple and it gives me error

Code: Select all

 File "pinaple", line 16
    PIDFILE=/var/run/$DAEMON_NAME.pid
            ^        ^
SyntaxError: invalid syntax
Pinaple is not a Python script, it's a special bash script that starts pinapled as a background 'daemon'. If you ran this command:

Code: Select all

sudo update-rc.d pinaple defaults
then pinapled should be started as a daemon when you boot the Pi. You can check that by typing

Code: Select all

sudo /etc/init.d/pinaple status
You can also start and stop it with

Code: Select all

sudo /etc/init.d/pinaple start
sudo /etc/init.d/pinaple stop
So, make sure the daemon is running, pair and trust the phone, and you should be good to go (fingers crossed)

Return to “Beginners”