Subject: Re: bug#20246: 25.0.50; Tramp does not show correct error message when ssh refuses to connect to host due to changed host key

From: Michael Albinus <[email-masked]>
Date: Fri, 10 Apr 2015 16:38:18 +0200

Filipp Gunbin <[email-masked]> writes:

Hi Filipp,

> That's what I can reproduce now:
>
> - change host identity in ~/.ssh/known-host
> - M-x tramp-cleanup-all-connections
> - C-x 4 r /ssh:user@host:/file
>
> Now, Tramp shows correct error message from ssh.

OK.

> - now, quit it with C-]
> - again C-x 4 r (as above)
>
> Now Tramp shows in the echo area: "/ssh:user@host:/file does not exist"
>
> This is the behavior which takes place if the above steps are done
> rather quickly.

"rather quickly" means within 10 seconds. This is the default value of
`remote-file-name-inhibit-cache', the time Tramp keeps its cache for a
given file.

> If I take a pause before retrying to visit a file, ssh error message is
> shown correctly.

OK.

> Maybe this is not the same problem I had originally, but that's what
> I'm able to reproduce right now.

Could you, please, apply the following patch:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/tramp/lisp/tramp.el.~master~	2015-04-10 16:34:06.421074752 +0200
--- /home/albinus/src/tramp/lisp/tramp.el	2015-04-10 16:29:29.236143227 +0200
***************
*** 3558,3563 ****
--- 3558,3565 ----
  	  (tramp-message vec 6 "\n%s" (buffer-string)))
  	(unless (eq exit 'ok)
  	  (tramp-clear-passwd vec)
+ 	  (tramp-flush-directory-property vec "")
+ 	  (tramp-flush-connection-property proc)
  	  (delete-process proc)
  	  (tramp-error-with-buffer
  	   (tramp-get-connection-buffer vec) vec 'file-error
--8<---------------cut here---------------end--------------->8---

This changes the behaviour that Tramp doesn't keep its cache anymore,
when there is an error during connection. Tramp reports that the
file/directory doesn't exist, and Emacs falls back to its default
behaviour, offering you a new empty buffer. This sounds consistent.

> Filipp

Best regards, Michael.