Next: , Previous: Remote shell setup, Up: Configuration

4.17 Android shell setup hints

tramp uses the adb method to access Android devices. Android devices provide a restricted shell access through an USB connection. The local host must have the Android SDK installed.

Applications such as SSHDroid that run sshd process on the Android device can accept any ssh-based methods provided these settings are adjusted:

sh must be specified for remote shell since Android devices do not provide /bin/sh. sh will then invoke whatever shell is installed on the device with this setting:

     (add-to-list 'tramp-connection-properties
     	     (list (regexp-quote "") "remote-shell" "sh"))

where ‘’ is the Android device's IP address. (see Predefined connection information).

tramp requires preserving PATH environment variable from user settings. Android devices prefer /system/xbin path over /system/bin. Both of these are set as follows:

     (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
     (add-to-list 'tramp-remote-path "/system/xbin")

When the Android device is not ‘rooted’, specify a writable directory for temporary files:

     (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")

Open a remote connection with the command C-x C-f /ssh:, where sshd is listening on port ‘2222’.

To add a corresponding entry to the ~/.ssh/config file (recommended), use this:

     Host android
          User root
          Port 2222

To use the host name ‘android’ instead of the IP address shown in the previous example, fix the connection properties as follows:

     (add-to-list 'tramp-connection-properties
     	     (list (regexp-quote "android") "remote-shell" "sh"))

Open a remote connection with a more concise command C-x C-f /ssh:android:.