0

With emacs 25.2.2 on Ubuntu 18.04, if I try opening a file over ssh using a path such as /ssh:somehost.example.com:/tmp/testfile, it launches a sub-process that does:

/usr/bin/ssh -o ControlPath=%C 0.0.0.1

This IP address does not accept ssh connections, so the ssh subprocess hangs, and the file opening in emacs also hangs until the ssh eventually times out. Using lsof, it can be seen that the TCP connection to 0.0.0.1:ssh is stuck in SYN_SENT state, consistent with it not receiving any response.

I found that it is possible to work around this by adding an iptables rule to reject the outgoing ssh connection to this address:

sudo iptables -A OUTPUT -d 0.0.0.1 -p tcp --dport 22 -j REJECT

so that this attempted ssh connection quickly receives a "connection refused", instead of the packet effectively being dropped and it just hanging. After this, emacs then connects to the actual target machine correctly, and the remote file can be edited.

Why is this connection to 0.0.0.1 being attempted, and how can this be prevented (in a way that does not require sudo access)?

2

The command /usr/bin/ssh -o ControlPath=%C 0.0.0.1 is used to check, whether your local ssh command accepts the ControlPath option. 0.0.0.1 is a non-existing address; ssh shall return immediately with an error.

In more recent Tramp versions, the blocking is avoided by using the command ssh -o ConnectTimeout=1 -o ControlPath=%C 0.0.0.1. I recommend to upgrade to the Tramp version provided by GNU ELPA.

| improve this answer | |
  • Thank you - I will investigate upgrading. – alani Sep 6 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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