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)?