Tramp: Waiting for prompts from remote shell

6,471

Solution 1

For me Tramp 2.1.19-pre with zsh and SSH kye authentication works using

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

in my ~/.emacs

Solution 2

I don't see how your remote shell could be the problem if tramp works with password authentication but not with key authentication.

A possible explanation is that ssh doesn't see your ssh agent when you run it from within Emacs. Can you log in to the remote machine using your key with ssh from a M-x shell or M-x term buffer? If your key has a passphrase, ssh needs to obtain the decrypted key somehow. It can prompt you directly (but I'm not sure if tramp would let the key prompt through), or it can launch an external program to prompt you for the key (this requires the environment variable SSH_ASKPASS to be set), or it can get the key from your ssh agent (this requires the environment variable SSH_AUTH_SOCK to be set). Your problem may be that you're not setting SSH_ASKPASS or SSH_AUTH_SOCK in the right place, so that it's not defined in your Emacs session.

Solution 3

The question has been answered but for people stumbling upon this, remember to check if your shell may ask for any user input before presenting the shell. For example oh-my-zsh checks for updates and asks for confirmation before installing them at shell startup. This will cause tramp to endlessly wait for a prompt, so make sure that login goes smoothly when you ssh before going down the tramp rabbithole.

Share:
6,471

Related videos on Youtube

grm
Author by

grm

Updated on September 17, 2022

Comments

  • grm
    grm over 1 year

    I have an issue with tramp against a specific host when I use ssh-keys for authentication. It works fine when I don't use ssh-key authentication, but I would like to prevent entering the password all the time.

    Don't know if it's related, but I use zsh for shell.

    I have followed both the tips of setting tramp-chunksize to 500 and adding the following code to .zshrc:

    if [[ "$TERM" == "dumb" ]]
    then
      unsetopt zle
      unsetopt prompt_cr
      unsetopt prompt_subst
      unfunction precmd
      unfunction preexec
      PS1='$ '
    fi
    

    But it's not working and it's still hanging with the message Tramp: Waiting for prompts from remote shell

    Any ideas on how to prevent this annoying issue? Thanks.

    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 13 years
      You should mention your operating system and version of Emacs, just in case. And how you normally enter your ssh key passphare, if any, is likely relevant.
    • Bill Burdick
      Bill Burdick over 4 years
      Well your approach worked for me, anyway...
  • wonderfulthunk
    wonderfulthunk over 3 years
    This solved my problem on OSX, Emacs 26.3 tramp 2.3.5.26.3 trying to tramp/ssh to a VM that was setup outside my control (it was a "provided by work" thing). I could ssh in just fine from bash/cli, but tramp would completely hang emacs. I think it may have been the prompt, in the format of [user@host-name:~] %?