SSH

> SSH

By default, you can get a remote shell on you smartwatch with the Android Debug Bridge tool and the “adb shell” command. However this shell suffers from a many limitations and you might prefer to get a standard SSH connection. To do so you need to setup a TCP connection with your watch. The procedure is different if you want to do it over USB or Wi-Fi (if your watch supports Wi-Fi)

SSH over USB

To use SSH over USB’s gadget mode you need to tell Connman to setup a manual IP for your watch. First of all, you need to get your usb’s UID thanks to the “get-services” tool which is available in the “connman-tests” package under /usr/lib/connman/test/. The first line of this command’s output should contain something like “gadget_UID_usb”, note this UID and replace it when needed in the commands below.

Create a /var/lib/connman/gadget_UID_usb/ directory and in that directory create a “settings” file containing:

[gadget_*UID*_usb]
Favorite=true
IPv4.method=manual
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.0.133
IPv4.gateway=192.168.0.1
AutoConnect=true
Name=Wired
IPv6.method=off
IPv6.privacy=disabled

Now from your computer, setup your usb interface with the 192.168.0.1 IP and then you’ll be able to connect to your watch with:

ssh ceres@192.168.0.133

/!\ This UID and the gadget’s mac address both seem to be re-generated at every boot so this config isn’t persistent. We should try to find a solution.

SSH over Wi-Fi

Dropbear is already running on the watch so we just need an IP address configured to connect.

Ensure wireless drivers are enabled for the watch.

Build your asteroid-image with iproute2 and wpa-supplicant. In meta-{watch}-hybris/conf/machine/{watch}.conf add iproute2 and wpa-supplicant to IMAGE_INSTALL:

IMAGE_INSTALL += "android-tools android-system msm-fb-refresher brcm-patchram-plus iproute2 wpa-supplicant"

Once your image is installed on the watch, open up an adb shell:

# mkdir /etc/wpa_supplicant
# cp /etc/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
# systemctl enable --now wpa_supplicant@wlan0
# wpa_cli
> scan
> scan_results
> add_network
> set_network X ssid "MYSSID"
> set_network X psk "MYPSK"
> enable_network X
> select_network X
> save_config
# ip a show dev wlan0

The watch should automatically get an IPv6 address from your network or you can set a static IPv4. You can disconnect from adb and connect via SSH.

By default, there is no root or ceres password, and no firewall rules.

About the author: kido