Using Emacs server and emacsclient on other machines as other users

后端 未结 4 1910
慢半拍i
慢半拍i 2020-12-12 13:09

I know that after I call (start-server) inside an existing Emacs session I can then use emacsclient -c (on the same computer) to create new frames

4条回答
  •  时光说笑
    2020-12-12 13:38

    I think what you're asking for is impossible by definition, because if you give a remote user unrestricted access to your Emacs, this is just as much "user spoofing" as letting that remote user access a shell via ssh. To spell it out, from a security point of view this is probably a bad idea.

    Also, the results of letting two users access one Emacs aren't as good as you might hope. It isn't designed with simultaneous access in mind. It's years since I tried it, so things might have moved on a bit, but when I did it was quirky to say the least.

    Still, I'll try to answer your question.

    It sounds like you're thinking about this back-to-front, because, counter-intuitively, in network terms, the X11 display is the server, and the X11 application is the client. This is surprising because typically the display is local to the user and the application is running on some remote server.

    You can instruct a running emacs to connect to a remote display and open a new window with M-x make-frame-on-display. For this to work, the owner of that display will need to grant you access to it.

    We will assume host-l is the computer that is running Emacs, and that you want to make it accessible to a user of display 0 on host-r. Be aware that you've said you don't want to use SSH forwarding, so following this method will cause all traffic will go across the network unencrypted.

    First, make sure that display host-r:0 is accepting TCP connections. You don't mention your operating system, but this is probably the default on Unix and probably isn't on Linux (for security reasons). If, for example, the following mentions -nolisten tcp then you'll need to change this configuration.

    host-r$ ps -ef | grep X
    

    Next, get the user of host-r to run the following, and send you the output. Be sure to warn them that this will allow you to take complete control of their current desktop session, should you choose.

    host-r$ xauth list $DISPLAY
    host-r/unix:0  MIT-MAGIC-COOKIE-1  01234567890abcdef0123456789abcd
    

    This is, effectively, the "password" for the display. On host-l, put it where Emacs will be able to find it with:

    host-l$ xauth add host-r:0 MIT-MAGIC-COOKIE-1  01234567890abcdef0123456789abcd
    

    Now enter M-x make-frame-on-display host-r:0 and an Emacs window should pop up on the remote display.

提交回复
热议问题