unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: help-gnu-emacs@gnu.org
Subject: aborting TRAMP / SSH passphrase prompt
Date: Thu, 23 Mar 2017 06:44:52 +0100	[thread overview]
Message-ID: <87shm4sg17.fsf@elephly.net> (raw)

Hi list,

I regularly encounter problems with TRAMP when trying to connect to a
server for the first time.  That alone is not the issue.  It is usually
easy to diagnose what went wrong and adjust the configuration.  What
bothers me, however, is that very often I end up in a state that I
cannot easily back out of, which results in a broken Emacs session.

The problem I had just now was that I was stuck in an unabortable
password prompt loop.

I tried to access a file on a remote server using a file name like this:

    /ssh:me@example.com#1022|root@example.com:/etc/foo.conf

(In my ~/.ssh/config that server has a section in which I specified the
port as 1022, and where I specified the identity file to be used, so
actually, this ad-hoc configuration in the file path should not have
been necessary.)

My TRAMP configuration looks like this:

--8<---------------cut here---------------start------------->8---
(require 'tramp)
(setq tramp-default-method "ssh")

(setq tramp-default-proxies-alist
      (list
       ;; Do not use a proxy on the same system.
       '((regexp-quote (system-name)) nil nil)
       ;; For root connections to remote hosts, log in via ssh with normal
       ;; user account first, then su/sudo to root
       '("example\\.com\\'" "\\`root\\'" "/ssh:%h:")
       ;; more servers…
       …))
;; respect the PATH variable on the remote machine
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(setq tramp-verbose 3)
--8<---------------cut here---------------end--------------->8---

I also disabled auto-save for remote files:

--8<---------------cut here---------------start------------->8---
(setq backup-directory-alist
      `(;; Do not backup or auto-save remote files to prevent delays.
        (,tramp-file-name-regexp . nil)
        ;; Write backup files to a dedicated directory.
        ("." . ,(expand-file-name
                 (concat user-emacs-directory "backups")))))
--8<---------------cut here---------------end--------------->8---

When I hit return to access the remote file I was given a passphrase
prompt.  I entered the correct passphrase to unlock my SSH key, but was
denied access.  So I decided to abort the passphrase prompt with C-g.

The prompt disappeared for a fraction of a second, but then reappeared.
I tried aborting again only to be presented with the prompt yet again.
I continued my attempts to abort and used ESC-ESC-ESC, which moved focus
away from the minibuffer.  The prompt reappeared but this time was not
focused and changing focus back to the minibuffer didn’t quite work.

It didn’t help that Emacs got into a state where it would show the
prompt but not accept *any* input (not even C-g).  This went on for
another 20 minutes until I remembered a workaround: kill the SSH
connection from outside.  So I looked for the SSH process spawned by
Emacs and found it:

    ssh -p 1022 -o ControlMaster=auto -o ControlPath=tramp.%C -o ControlPersist=no -e none example.com

Right after killing it, Emacs became usable again.  (Although even that
sometimes is not enough, if I remember correctly.)

I’m using Emacs 25.1.1 on a GNU system.

How can something like this be avoided in the future?  (Am I just
holding it wrong?)  Should I report this as a bug?  It’s hard to
reproduce this *exactly*, because each time it’s not clear to me how
*exactly* I got into this mess.

Any advice would be very welcome!  I really like TRAMP and would like to
avoid the frustration of seeing it fail in this way.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

PS: Please keep me in Cc as I’m not subscribed to this list.




             reply	other threads:[~2017-03-23  5:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23  5:44 Ricardo Wurmus [this message]
2017-03-23 14:23 ` aborting TRAMP / SSH passphrase prompt Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shm4sg17.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).