Skip to content

movsb/bletun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLETUN

Make a TCP connection from Bluetooth.

Use Case

SSH into a Linux machine, which is headless (e.g. Raspberry Pi Zero 2 W) or has a bad network configuration, without using a Display Monitor.

For Device

When you have network connection:

  1. Run make device to build the binary for device.
  2. Put the binary into /usr/local/bin.
  3. See Service below to make it auto start upon boot.

For Host

  1. Run make host

  2. Create a SSH config in ~/.ssh/config:

    Host zero
    	ProxyCommand bletun
  3. ssh zero and wait patiently, it will discover the first available device.

Note: Only one SSH connection is allowed at a time, which is a characteristic of Bluetooth connections. If you want multiple shells, use tmux.

Prerequisites

Packages:

  1. dbus
  2. bluez

Service

Systemd

File: /etc/systemd/system/bletun.service:

[Unit]
Description=bletun

# On Ubuntu, it changed? first it's sshd, it's now ssh.
#Requires=sshd.service
#After=sshd.service

[Service]
ExecStart=/usr/local/bin/bletun
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable:

$ sudo systemctl daemon-reload
$ sudo systemctl enable bletun.service

OpenRC

File: /etc/init.d/bletun:

/etc/init.d/bletun
#!/sbin/openrc-run

name="bletun"
command="/usr/local/bin/bletun"
pidfile="/run/bletun.pid"
command_background=true
supervisor=supervise-daemon
respawn_delay=5
respawn_max=0

depend() {
	need dbus bluetooth
}

Enable:

$ chmod +x /etc/init.d/bletun
$ rc-update add bletun default
$ service bletun restart

Security

There's no Bluetooth Paring. Anyone can connect to the same device. Authentication is done by SSH.

TODO

  • Flow Control: Sending is too fast, while Recv is too slow.
  • Allow more than one client.

Packages

 
 
 

Contributors