1

I'm trying to connect to my Android device via SSH using TRAMP. I've setup my SSHDroid, configured ssh keys and my ~/.ssh/config, so I'm able to connect with just ssh android from terminal.

But when trying to connect using TRAMP, it hangs with Tramp: Found remote shell prompt on ‘android’ message. I've configured my init.el according with https://www.gnu.org/software/emacs/manual/html_node/tramp/Android-shell-setup.html:

;; tramp
(require 'tramp)
(add-to-list 'tramp-connection-properties
    (list (regexp-quote "android") "remote-shell" "sh"))
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'tramp-remote-path "/system/xbin")
(add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")

And when changing the tramp-verbose to 10, the relevant part from log starts with the message 12:50:05.736545 tramp-open-shell (5) # Opening remote shell ‘sh’..., then it seems to enter infinite loop with this fragment:


12:50:05.742401 tramp-accept-process-output (10) # tramp/ssh android run t
exec env TERM='dumb' INSIDE_E
12:50:05.742490 tramp-get-connection-property (7) # check-remote-echo nil
12:50:05.742556 tramp-get-connection-property (7) # check-remote-echo nil
12:50:05.743037 tramp-accept-process-output (10) # tramp/ssh android run t
exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26.
ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26.                         <
1' ENV='' HISTFILE=~/.tra
_EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra                         <mp_history PROMPT_C
12:50:05.743140 tramp-get-connection-property (7) # check-remote-echo nil
12:50:05.743196 tramp-get-connection-property (7) # check-remote-echo nil
12:50:05.745363 tramp-accept-process-output (10) # tramp/ssh android run t
exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26.
ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26.                         <1' ENV='' HISTFILE=~/.tra
_EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra                         <mp_history PROMPT_COMMAND
26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND                         <='' PS1=#\$\  PS2='' PS3
tramp_history PROMPT_COMMAND='' PS1=#\$\  PS2='' PS3                         <='' sh 
(it grows longer the longer I wait) and finishes with 12:50:12.025467 tramp-open-shell (5) # Opening remote shell ‘sh’...failed after I press C-g.

So it looks like it fails to set the environment command and / or recognize the prompt. The weird thing is that it returns the correct prompt :/storage/emulated/0 $ in the logs. But I have no idea how to make it work.

I'm listing the full debug log below:


;; Emacs: 26.1 Tramp: 2.3.3.26.1 -- mode: outline; --
;; Location: /usr/share/emacs/26.1/lisp/net/tramp.elc Git: nil
12:50:05.222514 tramp-get-connection-property (7) # ~ undef
12:50:05.222603 tramp-get-connection-property (7) # process-name nil
12:50:05.222652 tramp-get-connection-property (7) # process-name nil
12:50:05.222696 tramp-get-connection-property (7) # process-buffer nil
12:50:05.222741 tramp-get-connection-property (7) # process-buffer nil
12:50:05.222778 tramp-set-connection-property (7) # process-buffer nil
12:50:05.222927 tramp-maybe-open-connection (3) # Opening connection for android using ssh...
12:50:05.230222 tramp-get-local-locale (7) # locale en_US.utf8
12:50:05.230335 tramp-get-connection-property (7) # login-args undef
12:50:05.230385 tramp-get-connection-property (7) # login-args undef
12:50:05.230450 tramp-ssh-controlmaster-options (4) # Computing ControlMaster options...
12:50:05.230508 tramp-call-process (6) # ‘ssh -o ControlMaster’ nil  temp
12:50:05.232686 tramp-call-process (6) # 255
command-line line 0: missing argument.
12:50:05.232770 tramp-call-process (6) # ‘ssh -o ConnectTimeout=1 -o ControlPath=%C 0.0.0.1’ nil  temp
12:50:05.235888 tramp-call-process (6) # 255
Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh: connect to host 0.0.0.1 port 22: Invalid argument
12:50:05.235972 tramp-call-process (6) # ‘ssh -o ControlPersist’ nil  temp
12:50:05.237822 tramp-call-process (6) # 255
command-line line 0: Missing ControlPersist argument.
12:50:05.237891 tramp-ssh-controlmaster-options (4) # Computing ControlMaster options...done
12:50:05.237958 tramp-get-connection-property (7) # process-name nil
12:50:05.238006 tramp-get-connection-property (7) # process-buffer nil
12:50:05.238446 tramp-set-connection-property (7) # vector (tramp-file-name ssh nil nil android nil  nil)
12:50:05.238529 tramp-maybe-open-connection (6) # /bin/sh -i
12:50:05.238577 tramp-get-connection-property (7) # vector (tramp-file-name ssh nil nil android nil  nil)
12:50:05.238626 tramp-get-connection-property (7) # check-remote-echo nil
12:50:05.238664 tramp-get-connection-property (7) # check-remote-echo nil
12:50:05.240829 tramp-accept-process-output (10) # tramp/ssh android run t

$

12:50:05.240889 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.240930 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.240975 tramp-wait-for-regexp (6) #

$

12:50:05.241027 tramp-get-connection-property (7) # login-program undef 12:50:05.241077 tramp-get-connection-property (7) # login-args undef 12:50:05.241121 tramp-get-connection-property (7) # login-env undef 12:50:05.241166 tramp-get-connection-property (7) # async-args undef 12:50:05.241210 tramp-get-connection-property (7) # connection-timeout undef 12:50:05.241252 tramp-get-connection-property (7) # temp-file undef 12:50:05.241328 tramp-set-connection-property (7) # temp-file /tmp/tramp.HsjOhR 12:50:05.241987 tramp-maybe-open-connection (3) # Sending command ‘exec ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none android’ 12:50:05.242048 tramp-get-connection-property (7) # process-name nil 12:50:05.242094 tramp-get-connection-property (7) # remote-echo nil 12:50:05.242135 tramp-send-command (6) # exec ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none android 12:50:05.242178 tramp-get-connection-property (7) # process-name nil 12:50:05.242220 tramp-get-connection-property (7) # chunksize nil 12:50:05.242260 tramp-set-connection-property (7) # last-cmd-time (23410 46045 242247 647000) 12:50:05.242303 tramp-send-string (10) # exec ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none android 12:50:05.242344 tramp-get-connection-property (7) # process-buffer nil 12:50:05.242401 tramp-set-connection-property (7) # first-password-request 12:50:05.242676 tramp-process-actions (3) # Waiting for prompts from remote shell... 12:50:05.727419 tramp-accept-process-output (10) # tramp/ssh android run t :/storage/emulated/0 $ 12:50:05.727679 tramp-process-one-action (5) # Looking for regexp "(.(user\|login)( .)?: )\'" from remote shell 12:50:05.727862 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.728047 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.728330 tramp-process-one-action (5) # Looking for regexp "(^.((?:adgangskode\|contrase(?:(?:ny\|ñ)a)\|geslo\|h(?:(?:asł\|esl)o)\|iphasiwedi\|jelszó\|l(?:ozinka\|ösenord)\|m(?:ot de passe\|ật khẩu)\|pa(?:rola\|s(?:ahitza\|s(?: phrase\|code\|ord\|phrase\|wor[dt])\|vorto))\|s(?:alasana\|enha\|laptažodis)\|wachtwoord\|лозинка\|пароль\|ססמה\|كلمة السر\|गुप्तशब्द\|शब्दकूट\|গুপ্তশব্দ\|পাসওয়ার্ড\|ਪਾਸਵਰਡ\|પાસવર્ડ\|ପ୍ରବେଶ ସଙ୍କେତ\|கடவுச்சொல்\|సంకేతపదము\|ಗುಪ್ತಪದ\|അടയാളവാക്ക്\|රහස්පදය\|ពាក្យសម្ងាត់\|パスワード\|密[码碼]\|암호)).*:\0? )\'" from remote shell 12:50:05.728540 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.728679 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.728948 tramp-process-one-action (5) # Looking for regexp "(^.(Connection (?:(?:clo\|refu)sed)\|Host key verification failed.\|Login (?:[Ii]ncorrect)\|N(?:ame or service not known\|o supported authentication methods left to try!)\|Permission denied\|(?:Sorry, try again\|Timeout, server not responding).).\|^.(Received signal [0-9]+).)\'" from remote shell 12:50:05.729126 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.729268 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.729469 tramp-process-one-action (5) # Looking for regexp "(^[^#$%> ][#$%>] *)\'" from remote shell 12:50:05.729622 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.729763 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.729934 tramp-process-one-action (5) # Call ‘tramp-action-succeed’ 12:50:05.730113 tramp-get-connection-property (7) # process-buffer nil 12:50:05.730270 tramp-process-actions (6) # :/storage/emulated/0 $ 12:50:05.730430 tramp-get-connection-property (7) # process-buffer nil 12:50:05.730848 tramp-process-actions (3) # Waiting for prompts from remote shell...done 12:50:05.731261 tramp-maybe-open-connection (3) # Found remote shell prompt on ‘android’ 12:50:05.731470 tramp-get-connection-property (7) # process-buffer nil 12:50:05.736420 tramp-get-connection-property (7) # remote-shell sh 12:50:05.736488 tramp-get-connection-property (7) # remote-shell sh 12:50:05.736545 tramp-open-shell (5) # Opening remote shell ‘sh’... 12:50:05.736660 tramp-get-connection-property (7) # process-name nil 12:50:05.736715 tramp-get-connection-property (7) # remote-echo nil 12:50:05.736761 tramp-send-command (6) # exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3='' sh 12:50:05.736810 tramp-get-connection-property (7) # process-name nil 12:50:05.736864 tramp-get-connection-property (7) # chunksize nil 12:50:05.736912 tramp-set-connection-property (7) # last-cmd-time (23410 46045 736897 362000) 12:50:05.736966 tramp-send-string (10) # exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3='' sh 12:50:05.737015 tramp-get-connection-property (7) # process-buffer nil 12:50:05.737083 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.737134 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.742401 tramp-accept-process-output (10) # tramp/ssh android run t exec env TERM='dumb' INSIDE_E 12:50:05.742490 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.742556 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.743037 tramp-accept-process-output (10) # tramp/ssh android run t exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_C 12:50:05.743140 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.743196 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.745363 tramp-accept-process-output (10) # tramp/ssh android run t exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh 12:50:05.745484 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.745547 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.771143 tramp-accept-process-output (10) # tramp/ssh android run t exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:05.771463 tramp-get-connection-property (7) # check-remote-echo nil 12:50:05.771628 tramp-get-connection-property (7) # check-remote-echo nil 12:50:06.773377 tramp-accept-process-output (10) # tramp/ssh android run nil exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:06.773716 tramp-get-connection-property (7) # check-remote-echo nil 12:50:06.773881 tramp-get-connection-property (7) # check-remote-echo nil 12:50:07.775587 tramp-accept-process-output (10) # tramp/ssh android run nil exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:07.775882 tramp-get-connection-property (7) # check-remote-echo nil 12:50:07.776043 tramp-get-connection-property (7) # check-remote-echo nil 12:50:08.777729 tramp-accept-process-output (10) # tramp/ssh android run nil exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:08.778098 tramp-get-connection-property (7) # check-remote-echo nil 12:50:08.778262 tramp-get-connection-property (7) # check-remote-echo nil 12:50:09.780029 tramp-accept-process-output (10) # tramp/ssh android run nil exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:09.780357 tramp-get-connection-property (7) # check-remote-echo nil 12:50:09.780532 tramp-get-connection-property (7) # check-remote-echo nil 12:50:10.781488 tramp-accept-process-output (10) # tramp/ssh android run nil exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:10.781781 tramp-get-connection-property (7) # check-remote-echo nil 12:50:10.781937 tramp-get-connection-property (7) # check-remote-echo nil 12:50:11.782759 tramp-accept-process-output (10) # tramp/ssh android run nil exec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. ec env TERM='dumb' INSIDE_EMACS='26.1,tramp:2.3.3.26. <1' ENV='' HISTFILE=~/.tra _EMACS='26.1,tramp:2.3.3.26.1' ENV='' HISTFILE=~/.tra <mp_history PROMPT_COMMAND 26.1' ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND <='' PS1=#\$\ PS2='' PS3 tramp_history PROMPT_COMMAND='' PS1=#\$\ PS2='' PS3 <='' sh :/storage/emulated/0 $ 12:50:11.783052 tramp-get-connection-property (7) # check-remote-echo nil 12:50:11.783214 tramp-get-connection-property (7) # check-remote-echo nil 12:50:12.025467 tramp-open-shell (5) # Opening remote shell ‘sh’...failed 12:50:12.025968 tramp-maybe-open-connection (3) # Opening connection for android using ssh...failed 12:50:12.028822 tramp-set-connection-property (7) # remote-shell sh 12:50:12.029085 tramp-get-file-property (8) # file-truename nil 12:50:12.029276 tramp-flush-directory-property (8) # 12:50:12.029460 tramp-get-connection-property (7) # process-name nil 12:50:12.029632 tramp-get-connection-property (7) # process-name nil 12:50:12.029805 tramp-flush-connection-property (7) # tramp/ssh android (vector temp-file last-cmd-time) 12:50:12.029997 tramp-get-connection-property (7) # process-name nil 12:50:12.032534 tramp-flush-connection-property (7) # (tramp-file-name ssh nil nil android nil nil nil) (remote-shell process-buffer first-password-request) 12:50:12.032649 tramp-set-connection-property (7) # remote-shell sh 12:50:12.032704 tramp-get-connection-property (7) # process-buffer nil 12:50:12.032804 tramp-file-name-handler (1) # Interrupt received in operation (expand-file-name /ssh:android: /) 12:50:14.521367 tramp-get-connection-property (7) # case-insensitive undef 12:53:46.292938 tramp-get-connection-property (7) # case-insensitive undef 12:54:51.071295 tramp-get-connection-property (7) # case-insensitive undef 12:57:14.209581 tramp-get-connection-property (7) # case-insensitive undef

2
  • 1
    I've found one workaround - using adb. After connecting the cable, enabling usb debugging in developer options on my phone and starting the adb-server, I'm able to connect with: C-x C-f /:adb::/storage/emulated/0
    – tlegutko
    Commented Aug 14, 2018 at 12:03
  • 1
    I'm happy that adb works for you. If you want to get the ssh connection working, I recommend that you contact the Tramp mailing list. It is important to add the debug buffer as attachment, because every bit (and non-ascii char) counts. Reading the whole trace buffer here in sx shows only ascii formatted text. Commented Aug 14, 2018 at 16:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.