1

I have 2 operating systems: Windows XP and Linux Slackware.

In both operating systems I have the following text in ~/.ssh/config:

Host beta
HostName <server IP>
User beta
Port 22

I can connect to ssh directly from shells, using the command: ssh beta. When I run C-x C-f and then /ssh:beta:/home/beta in Linux it works, the directory is opened in dired. On Windows it hangs. In *Messages* buffer I get the following:

Tramp: Opening connection for beta using ssh...
Tramp: Sending command `ssh   -o ControlMaster=auto -o ControlPath='tramp.%r@%h:%p' -o ControlPersist=no -e none beta && exit || exit'
Tramp: Waiting for prompts from remote shell...failed
Tramp: Opening connection for beta using ssh...failed

How to fix?

5
  • What is your ssh client? WinXP has none by default, so that's critical information. I'm slightly dubious that ControlMaster is available on Windows (it's certainly not if you're using Cygwin, last I knew). It used to be the case that you needed to use the sshx tramp method with a Cygwin-based ssh client, so try that? (or plink if you're using PuTTY).
    – phils
    Commented Apr 27, 2016 at 8:26
  • @phils I have Cygwin ssh client on Windows: OpenSSH_6.2p2, OpenSSL 1.0.1e 11 Feb 2013. It works both from cygwin bash shell and from Windows command prompt.
    – user4035
    Commented Apr 27, 2016 at 8:40
  • There are known issues with Cygwin and Tramp when it comes to transfer the password. Does Emacs asks you for the remote password? If yes, please use ssh agent in order to avoid this. Commented Apr 27, 2016 at 12:01
  • @MichaelAlbinus "Does Emacs asks you for the remote password?" - no
    – user4035
    Commented Apr 27, 2016 at 17:34
  • 2
    Then pls apply (setq tramp-verbose 10). Rerun your test. There will be a Tramp debug buffer, which shall tell us the story. Commented Apr 27, 2016 at 18:50

2 Answers 2

4

Try sshx command instead of ssh when opening with C-x C-f

For more, search sshx at https://www.gnu.org/software/tramp/

1
  • 1
    This should be the answer. It's the only way I could TRAMP get working with ssh on Windows. From the docs: ‘sshx’ is useful for MS Windows users when ‘ssh’ triggers an error about allocating a pseudo tty. This happens due to missing shell prompts that confuses TRAMP.
    – jobor
    Commented Sep 25, 2023 at 20:26
0

This worked for me on :

The changes from the original tramp-sh.el is

  • for cygwin, use fakecygpty with ssh and change the prompt to ##
  • for plink, remove -ssh option

I have also renamed these method with w to differentiate it.

(when (string-equal system-type "windows-nt")
  (add-to-list 'tramp-methods
               `("sshw"
                 (tramp-login-program        "fakecygpty ssh")
                 ;; ("%h") must be a single element, see `tramp-compute-multi-hops'.
                 (tramp-login-args           (("-l" "%u" "-o \"StrictHostKeyChecking=no\"") ("-P" "%p") ("-t")
                                              ("%h") ("\"")
                                              (,(format
                                                 "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
                                                 tramp-terminal-type
                                                 "##"))
                                              ("/bin/sh") ("\"")))
                 (tramp-remote-shell         "/bin/sh")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-default-port         22))
               )

  (add-to-list 'tramp-methods
               `("plinkw"
                 (tramp-login-program        "plink")
                 ;; ("%h") must be a single element, see `tramp-compute-multi-hops'.
                 (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-t")
                                              ("%h") ("\"")
                                              (,(format
                                                 "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
                                                 tramp-terminal-type
                                                 "$"))
                                              ("/bin/sh") ("\"")))
                 (tramp-remote-shell         "/bin/sh")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-default-port         22))
               )
  )

Your Answer

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

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