Forwarding X11 over SSH if the server configuration doesn't allow it

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
8
down vote

favorite
3












Consider a situation where I'm logging in over SSH from machine A to machine B, I have an X session on machine A, and I want to run an X program on B.



ssh -X B makes this work transparently. But what if the server configuration lacks X11Forwarding yes, I don't have root permissions on the server, and the server administrator is indifferent?



It's obviously possible to forward the X11 connection, since I can transfer whatever I want over the SSH channel. In fact, if the local X server allows TCP connections, it's as easy as ssh -R 6010:localhost:6000 (to be adjusted for the display numbers). What about the common case where the local X server only allows socket connections? How do I do X forwarding conveniently and securely, with a minimum of installation requirements (especially on B)?










share|improve this question



























    up vote
    8
    down vote

    favorite
    3












    Consider a situation where I'm logging in over SSH from machine A to machine B, I have an X session on machine A, and I want to run an X program on B.



    ssh -X B makes this work transparently. But what if the server configuration lacks X11Forwarding yes, I don't have root permissions on the server, and the server administrator is indifferent?



    It's obviously possible to forward the X11 connection, since I can transfer whatever I want over the SSH channel. In fact, if the local X server allows TCP connections, it's as easy as ssh -R 6010:localhost:6000 (to be adjusted for the display numbers). What about the common case where the local X server only allows socket connections? How do I do X forwarding conveniently and securely, with a minimum of installation requirements (especially on B)?










    share|improve this question

























      up vote
      8
      down vote

      favorite
      3









      up vote
      8
      down vote

      favorite
      3






      3





      Consider a situation where I'm logging in over SSH from machine A to machine B, I have an X session on machine A, and I want to run an X program on B.



      ssh -X B makes this work transparently. But what if the server configuration lacks X11Forwarding yes, I don't have root permissions on the server, and the server administrator is indifferent?



      It's obviously possible to forward the X11 connection, since I can transfer whatever I want over the SSH channel. In fact, if the local X server allows TCP connections, it's as easy as ssh -R 6010:localhost:6000 (to be adjusted for the display numbers). What about the common case where the local X server only allows socket connections? How do I do X forwarding conveniently and securely, with a minimum of installation requirements (especially on B)?










      share|improve this question















      Consider a situation where I'm logging in over SSH from machine A to machine B, I have an X session on machine A, and I want to run an X program on B.



      ssh -X B makes this work transparently. But what if the server configuration lacks X11Forwarding yes, I don't have root permissions on the server, and the server administrator is indifferent?



      It's obviously possible to forward the X11 connection, since I can transfer whatever I want over the SSH channel. In fact, if the local X server allows TCP connections, it's as easy as ssh -R 6010:localhost:6000 (to be adjusted for the display numbers). What about the common case where the local X server only allows socket connections? How do I do X forwarding conveniently and securely, with a minimum of installation requirements (especially on B)?







      ssh xorg xforwarding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 13 '17 at 12:36









      Community♦

      1




      1










      asked May 6 '11 at 22:52









      Gilles

      511k12010141543




      511k12010141543




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          1. Spin up an additional X server using Xephyr. This is for security — it prevents the remote system from compromising yours.


          2. Use SSH to forward a remote socket to the Xephyr socket. SSH supports forwarding Unix sockets, too.


          3. Set the environment variables on the remote server correctly.






          share|improve this answer



























            up vote
            5
            down vote













            Is the protocol X11 speaks when talking to a tcp port any different when talking to a socket?



            Perhaps you could combine your own suggested use of ssh -R 6010:localhost:6000 to bring the X11 data in over port forwarding, then bridge the local gab between the tcp port and the X11 socket listener with nc like:



            nc -l -p 6000 > /tmp/.X11-unix/X0





            share|improve this answer






















            • Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
              – Gilles
              May 7 '11 at 10:13






            • 1




              There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
              – Caleb
              May 7 '11 at 10:21






            • 3




              I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
              – Gilles
              May 7 '11 at 10:56










            • @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
              – Caleb
              May 7 '11 at 11:04










            • For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
              – Samveen
              Jun 5 '15 at 5:17










            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f12777%2fforwarding-x11-over-ssh-if-the-server-configuration-doesnt-allow-it%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            1. Spin up an additional X server using Xephyr. This is for security — it prevents the remote system from compromising yours.


            2. Use SSH to forward a remote socket to the Xephyr socket. SSH supports forwarding Unix sockets, too.


            3. Set the environment variables on the remote server correctly.






            share|improve this answer
























              up vote
              1
              down vote



              accepted










              1. Spin up an additional X server using Xephyr. This is for security — it prevents the remote system from compromising yours.


              2. Use SSH to forward a remote socket to the Xephyr socket. SSH supports forwarding Unix sockets, too.


              3. Set the environment variables on the remote server correctly.






              share|improve this answer






















                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                1. Spin up an additional X server using Xephyr. This is for security — it prevents the remote system from compromising yours.


                2. Use SSH to forward a remote socket to the Xephyr socket. SSH supports forwarding Unix sockets, too.


                3. Set the environment variables on the remote server correctly.






                share|improve this answer












                1. Spin up an additional X server using Xephyr. This is for security — it prevents the remote system from compromising yours.


                2. Use SSH to forward a remote socket to the Xephyr socket. SSH supports forwarding Unix sockets, too.


                3. Set the environment variables on the remote server correctly.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 8 at 5:16









                Demi

                30337




                30337






















                    up vote
                    5
                    down vote













                    Is the protocol X11 speaks when talking to a tcp port any different when talking to a socket?



                    Perhaps you could combine your own suggested use of ssh -R 6010:localhost:6000 to bring the X11 data in over port forwarding, then bridge the local gab between the tcp port and the X11 socket listener with nc like:



                    nc -l -p 6000 > /tmp/.X11-unix/X0





                    share|improve this answer






















                    • Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
                      – Gilles
                      May 7 '11 at 10:13






                    • 1




                      There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
                      – Caleb
                      May 7 '11 at 10:21






                    • 3




                      I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
                      – Gilles
                      May 7 '11 at 10:56










                    • @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
                      – Caleb
                      May 7 '11 at 11:04










                    • For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
                      – Samveen
                      Jun 5 '15 at 5:17














                    up vote
                    5
                    down vote













                    Is the protocol X11 speaks when talking to a tcp port any different when talking to a socket?



                    Perhaps you could combine your own suggested use of ssh -R 6010:localhost:6000 to bring the X11 data in over port forwarding, then bridge the local gab between the tcp port and the X11 socket listener with nc like:



                    nc -l -p 6000 > /tmp/.X11-unix/X0





                    share|improve this answer






















                    • Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
                      – Gilles
                      May 7 '11 at 10:13






                    • 1




                      There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
                      – Caleb
                      May 7 '11 at 10:21






                    • 3




                      I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
                      – Gilles
                      May 7 '11 at 10:56










                    • @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
                      – Caleb
                      May 7 '11 at 11:04










                    • For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
                      – Samveen
                      Jun 5 '15 at 5:17












                    up vote
                    5
                    down vote










                    up vote
                    5
                    down vote









                    Is the protocol X11 speaks when talking to a tcp port any different when talking to a socket?



                    Perhaps you could combine your own suggested use of ssh -R 6010:localhost:6000 to bring the X11 data in over port forwarding, then bridge the local gab between the tcp port and the X11 socket listener with nc like:



                    nc -l -p 6000 > /tmp/.X11-unix/X0





                    share|improve this answer














                    Is the protocol X11 speaks when talking to a tcp port any different when talking to a socket?



                    Perhaps you could combine your own suggested use of ssh -R 6010:localhost:6000 to bring the X11 data in over port forwarding, then bridge the local gab between the tcp port and the X11 socket listener with nc like:



                    nc -l -p 6000 > /tmp/.X11-unix/X0






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 7 '11 at 10:11

























                    answered May 7 '11 at 10:02









                    Caleb

                    49.3k9146185




                    49.3k9146185











                    • Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
                      – Gilles
                      May 7 '11 at 10:13






                    • 1




                      There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
                      – Caleb
                      May 7 '11 at 10:21






                    • 3




                      I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
                      – Gilles
                      May 7 '11 at 10:56










                    • @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
                      – Caleb
                      May 7 '11 at 11:04










                    • For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
                      – Samveen
                      Jun 5 '15 at 5:17
















                    • Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
                      – Gilles
                      May 7 '11 at 10:13






                    • 1




                      There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
                      – Caleb
                      May 7 '11 at 10:21






                    • 3




                      I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
                      – Gilles
                      May 7 '11 at 10:56










                    • @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
                      – Caleb
                      May 7 '11 at 11:04










                    • For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
                      – Samveen
                      Jun 5 '15 at 5:17















                    Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
                    – Gilles
                    May 7 '11 at 10:13




                    Yes, that's the idea. But I was hoping for an answer saying “put this in your .ssh/config client-side and that in your .profile server-side, and then just run ssh B”.
                    – Gilles
                    May 7 '11 at 10:13




                    1




                    1




                    There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
                    – Caleb
                    May 7 '11 at 10:21




                    There is an easy "put this in your config" answer, the problem is you rule that out in your question qualifications because the option you need goes in the sshd_config side of things on B. You're trying to work around a block put in place to make it hard to inadvertently open up a security issue.
                    – Caleb
                    May 7 '11 at 10:21




                    3




                    3




                    I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
                    – Gilles
                    May 7 '11 at 10:56




                    I'm targeting the (in my experience very common) case where the admin doesn't care and just left the default settings in place. X11 forwarding isn't banned by policy, it's just inconvenience by sysadmin indifference. Anyway X11 forwarding allows the server to attack the client, so banning it server-side doesn't make much sense.
                    – Gilles
                    May 7 '11 at 10:56












                    @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
                    – Caleb
                    May 7 '11 at 11:04




                    @Gilles I agree the default doesn't really protect against anything useful. So should we lobby to get the default changed upstream?
                    – Caleb
                    May 7 '11 at 11:04












                    For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
                    – Samveen
                    Jun 5 '15 at 5:17




                    For me, /tmp/.X11-unix/X0 is a unix domain socket, not a FIFO, so any redirection attempt ends with ENXIO: No such device.
                    – Samveen
                    Jun 5 '15 at 5:17

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f12777%2fforwarding-x11-over-ssh-if-the-server-configuration-doesnt-allow-it%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay