2

I am able to clone a session after configure the configure file under .ssh

cat .ssh/config
host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
ServerAliveInterval 60

After I connect to the remote server once, then I don't need to input password to it when connect to it the second time using the clone session approach.

But looks like emacs couldn't clone the session. When I open a file on emacs, it still need to ask for password. Is there anything additional need to configure?

The tramp I am using is:

tramp is a built-in package.

     Status: Built-In.
    Version: 2.2.13.25.1
    Summary: Transparent Remote Access, Multiple Protocol
Other versions: 2.2.13.25.1 (builtin).

After I added the following to the .spacemacs (I am using spacemac).

  (setq tramp-debug-buffer t)
  (setq tramp-verbose 9)

In in the debug buffer I will see it has the following and hangs there.

;; GNU Emacs: 25.1.1 Tramp: 2.2.13.25.1 -*- mode: outline; -*-
16:03:10.771969 tramp-get-file-property (8) #  file-attributes-string nil
16:03:10.772297 tramp-get-connection-property (7) # stat undef
16:03:10.772372 tramp-get-remote-stat (5) # Finding a suitable ‘stat’ command
16:03:10.772442 tramp-get-connection-property (7) # remote-path undef
16:03:10.772521 tramp-get-connection-property (7) # process-name nil
16:03:10.772591 tramp-get-connection-property (7) # process-name nil
16:03:10.772655 tramp-get-connection-property (7) # process-buffer nil
16:03:10.772759 tramp-file-name-handler (5) # Non-essential received in operation (file-attributes /ssh:test-server: string)
16:03:10.773157 tramp-get-connection-property (7) # uid-string nil
16:03:10.773240 tramp-get-connection-property (7) # gid-string nil
16:03:10.773315 tramp-get-file-property (8) #  file-attributes-integer nil
16:03:10.773769 tramp-get-connection-property (7) # stat undef
16:03:10.773839 tramp-get-remote-stat (5) # Finding a suitable ‘stat’ command
16:03:10.773903 tramp-get-connection-property (7) # remote-path undef
16:03:10.773973 tramp-get-connection-property (7) # process-name nil
16:03:10.774048 tramp-get-connection-property (7) # process-name nil
16:03:10.774115 tramp-get-connection-property (7) # process-buffer nil
16:03:10.774194 tramp-file-name-handler (5) # Non-essential received in operation (file-attributes /ssh:test-server:)
16:03:10.774587 tramp-get-connection-property (7) # uid-integer nil
16:03:10.774665 tramp-get-connection-property (7) # gid-integer nil
16:03:10.774756 tramp-get-connection-property (7) # test undef
16:03:10.774820 tramp-get-test-command (5) # Finding a suitable ‘test’ command
16:03:10.774887 tramp-get-connection-property (7) # process-name nil
16:03:10.774959 tramp-get-connection-property (7) # process-name nil
16:03:10.775027 tramp-get-connection-property (7) # process-buffer nil
16:03:10.775106 tramp-file-name-handler (5) # Non-essential received in operation (file-readable-p /ssh:test-server:)
16:03:18.005921 tramp-get-file-property (8) #  file-attributes-integer nil
16:03:18.006013 tramp-get-file-property (8) #  file-attributes-string nil
16:03:18.006082 tramp-get-connection-property (7) # file-exists undef
16:03:18.006163 tramp-get-file-exists-command (5) # Finding command to check if file exists
16:03:18.006258 tramp-get-connection-property (7) # test undef
16:03:18.006321 tramp-get-test-command (5) # Finding a suitable ‘test’ command
16:03:18.006399 tramp-get-connection-property (7) # process-name nil
16:03:18.006467 tramp-get-connection-property (7) # process-name nil
16:03:18.006540 tramp-get-connection-property (7) # process-buffer nil
16:03:18.006648 tramp-file-name-handler (5) # Non-essential received in operation (file-exists-p /ssh:test-server:)
7
  • 1
    Which Emacs / Tramp version are you using? Recent Tramp offers several variables for configuring this. Set tramp-use-ssh-controlmaster-options to nil, Tramp shouldn't overwrite your settings then. Oct 24, 2016 at 14:36
  • The version is 2.2.13.25.1. I tried to set tramp-use-ssh-controlmaster-options to nil, this time it works for normal server. But if a server need 2-factor authentication, looks like it hangs there after typing: /ssh:server: Normally it should prompt a file list to choose from after typed /ssh:server: .But now it just hang.
    – Daniel Wu
    Oct 25, 2016 at 1:33
  • Try customizing the tramp-verbose option to get more info on where it's hanging.
    – phils
    Oct 25, 2016 at 1:58
  • @phils, I have added the debug info, the last log info is:16:03:18.006648 tramp-file-name-handler (5) # Non-essential received in operation (file-exists-p /ssh:test-server:)
    – Daniel Wu
    Oct 25, 2016 at 8:07
  • 1
    If you have 2-factor authentication, you must configure it in Tramp. See the Tramp manual, section Frequently Asked Questions, for the tramp-actions-before-shell example. Oct 25, 2016 at 8:12

2 Answers 2

0

Do you have a custom shell prompt? If so, try adding this to your config, this fixed it for me

(setq tramp-shell-prompt-pattern "\\(?:^\\|\r\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-zA-Z] *\\)*")

Reference https://www.emacswiki.org/emacs/TrampMode#toc12

1
  • This. 99% of the time if TRAMP hangs it is because it didn’t recognize the prompt.
    – db48x
    Aug 12 at 20:57
0

After searching and trying various answers, I found that none of them seemed to fix my problem, but removing two customizations did fix it: specifically, for

  • tramp-syntax (I had this set to 'simplified previously)
  • tramp-default-method (I had this set to "ssh" previously)

(To those who come after me: sorry, having spent all this time I didn't test if only one of those settings was a problem, or both. Anyone who can narrow it down further: thanks very much!)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.