Subject: bug#25050: 25.1; Tramp: Trying to connect to an Android device

From: Michael Albinus <[email-masked]>
Date: Mon, 28 Nov 2016 20:06:07 +0100

Arash <[email-masked]> writes:

Hi Arash,

> I'm trying to connect to my Android device which runs SSHelper as ssh
> daemon but tramp hangs on "Tramp: Found remote shell prompt on
> ‘192.168.2.22’".
> I also followed the guide
> (https://www.gnu.org/software/emacs/manual/html_node/tramp/Android-shell-setup.html)
> but it isn't working.

Thanks for the report. Let's see what's up:

> 14:31:08.801416 tramp-send-command (6) # exec ssh -l u0_a82  -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none 192.168.2.22
> 14:31:09.137629 tramp-process-actions (6) #
> SSHelper Version 8.5 Copyright 2014, P. Lutus
> Odroid-c2:3.14.29
> u0_a82@odroidc2:/data/data/com.arachnoid.sshelper/home $

That's good. Tramp is able to connect your Android device via ssh.

> 14:31:09.138347 tramp-send-command (6) # exec env ENV='' HISTFILE=.tramp_history PROMPT_COMMAND='' PS1=\#\$\  PS2='' PS3='' sh

Now Tramp tries to open a local shell. It also tries to set the prompt
to "#$ ".

> 14:31:19.184572 tramp-accept-process-output (10) # *tramp/ssh [email-masked]* run *tramp/ssh [email-masked]*
> exec env ENV='' HISTF.xec env ENV='' HISTF
> <^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HILE=.tramp_history
> PROMPT_COMMAND='' PS1=\#\$\ PS2='' PS3.tramp_history PROMPT_COMMAND=''
> PS1=\#\$\ PS2='' PS3
> <^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H='' sh .
> u0_a82@odroidc2:/data/data/com.arachnoid.sshelper/home $

This fails badly, as we see :-(

For readability, I've replaced the character C-h (code 8) by ^H.

Do you see a chance to use another shell but "sh" on your Android
device? And alternatively, would Tramp's "adb" method an option for you?

Best regards, Michael.