Re: Remote TCP server through ssh tunnel
Peter Oliver <p.d.oliver <at> mavit.org.uk>
2010-10-25 17:28:27 GMT
On Mon, 25 Oct 2010, Lluís wrote:
> Ken Raeburn writes:
>
>> On Oct 24, 2010, at 12:48, Lluís wrote:
>>> I've tried with this:
>>>
>>> server$ emacs --daemon --eval '(setq server-use-tcp t server-host "0.0.0.0")'
>>> server$ netstat -nap | grep emacs
>>> tcp 0 0 0.0.0.0:13501 0.0.0.0:* LISTEN 12078/emacs
>>> server$ ssh -R 13502:localhost:13501 firewall
>>> client$ ssh -L 13501:localhost:13502 vilanova <at> gso.ac.upc.edu
>>> # I already have an existing tunnel for ssh connections to server
>>> client$ scp server:.emacs.d/server/server /tmp/server
>>> client$ sed -i -e s/0.0.0.0/127.0.0.1/ /tmp/server
>>> client$ emacsclient -f /tmp/server -c
>>> Waiting for Emacs...
>>> *ERROR*: Display :0.0 can't be opened
>>> [Exit 1 ]
>>
>> If your SSH path through is forwarding X11 as well as TCP connections,
>> you need to find the server-side name for that forwarded "display" and
>> give it to emacsclient to pass through. I think that'll work; I
>> haven't tried it.
I've tried it, and can confirm that it does work.
> That's what I do, but is not comfortable for high delay network
> connections. As I said, I expected to run locally "as much as possible",
> but modify everything remotely.
I think you misunderstand. The suggestion here isn't that you should
run emacs over X11. The other person is pointing out that SSH arranges
this for you in a way that confuses emacsclient. All this talk of
"servers" is rather confusing when your X11 server is at the opposite
end of the connection to your SSH server
Try the following:
server$ echo $DISPLAY
# Confirm that you can connect to this display by running, e.g.,
server$ xdpyinfo
# Then:
client$ export DISPLAY="<value from echo, above>"
Anyway, as people have mentioned, I think you should look into Tramp.
I call emacsclient with a simple shell wrapper that prefixes
"/ssh:login <at> host:" to the file name. Emacs then fetches the
file for me for local editing.
If you re-use your existing SSH connections by adding, e.g.,
ControlMaster auto
ControlPath ~/.ssh/mux/%r <at> %h:%p
to your ~/.ssh/config, this is all perfectly speedy.
--
--
Peter Oliver