6

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.

2
  • 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. Aug 23, 2010 at 21:48
  • Well your approach worked for me, anyway... Sep 22, 2019 at 7:38

3 Answers 3

7

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

1
  • 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:~] %? Nov 30, 2020 at 16:37
3

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.

1
  • It works with both M-x shell and M-x term. Tramp logs the command 'ssh <hostname> -l <username> -q -e none && exit || exit' (which also works fine with M-x shell or M-x term).
    – grm
    Aug 24, 2010 at 6:30
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .