Serve Internet to remote machine via SSH session?












16















The machine via which I'm SSHing to the remote/host machine (same network/LAN) has access to the Internet but the host doesn't.



Running updates and installing packages on the host gets quite inconvenient because then I have to start a proxy locally and then configure the remote machine to use it.



So I was wondering if there is a easier way of doing this via, maybe, SSH or something else?



I have a realization of the complexities that lie within, but was curious to know.



Using plink through Emacs (if it matters).










share|improve this question





























    16















    The machine via which I'm SSHing to the remote/host machine (same network/LAN) has access to the Internet but the host doesn't.



    Running updates and installing packages on the host gets quite inconvenient because then I have to start a proxy locally and then configure the remote machine to use it.



    So I was wondering if there is a easier way of doing this via, maybe, SSH or something else?



    I have a realization of the complexities that lie within, but was curious to know.



    Using plink through Emacs (if it matters).










    share|improve this question



























      16












      16








      16


      11






      The machine via which I'm SSHing to the remote/host machine (same network/LAN) has access to the Internet but the host doesn't.



      Running updates and installing packages on the host gets quite inconvenient because then I have to start a proxy locally and then configure the remote machine to use it.



      So I was wondering if there is a easier way of doing this via, maybe, SSH or something else?



      I have a realization of the complexities that lie within, but was curious to know.



      Using plink through Emacs (if it matters).










      share|improve this question
















      The machine via which I'm SSHing to the remote/host machine (same network/LAN) has access to the Internet but the host doesn't.



      Running updates and installing packages on the host gets quite inconvenient because then I have to start a proxy locally and then configure the remote machine to use it.



      So I was wondering if there is a easier way of doing this via, maybe, SSH or something else?



      I have a realization of the complexities that lie within, but was curious to know.



      Using plink through Emacs (if it matters).







      ssh proxy internet






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 25 '14 at 23:44









      Gilles

      539k12810921606




      539k12810921606










      asked Feb 25 '14 at 13:48









      Bleeding FingersBleeding Fingers

      4511821




      4511821






















          2 Answers
          2






          active

          oldest

          votes


















          17














          Let's call the machine that has internet access hasinet and the one that doesn't noinet.



          If you can make an SSH connection from noinet to hasinet



          You can do this easily with OpenSSH's built-in SOCKS proxy. This command will set up a SOCKS proxy on noinet listening on port 1080:



          noinet$ ssh -D 1080 hasinet


          If you can only make SSH connections to noinet from hasinet



          You can run OpenSSH's SOCKS proxy on hasinet and then forward a port from noinet to hasinet. This can cleverly be done with one command like so (thanks @Patrick):



          hasinet$ ssh -D 1080 localhost -t ssh -R 1080:localhost:1080 noinet


          How to use the SOCKS proxy



          How you use this proxy will depend on the application. Some applications have support for SOCKS proxies built in. If that's the case, you'll need to configure your app to use the proxy on localhost:1080. If not, you can use proxychains or redsocks, as @sciurus suggests. tsocks is a lighter-weight solution if you only need to provide network access for some commands.






          share|improve this answer





















          • 1





            Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

            – Patrick
            Feb 26 '14 at 4:29













          • Oh yeah, that'll totally work. Thanks!

            – smammy
            Feb 27 '14 at 5:00



















          2














          Here's a way to do this via SSH:



          On the machine with no internet access, run



          ssh -D 8080 machine_with_internet_access


          You can replace 8080 with any unused port number,



          Then install software like proxychains or redsocks, configure them to connect to localhost:8080, and run software that needs internet access through them.






          share|improve this answer























            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            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%2f116867%2fserve-internet-to-remote-machine-via-ssh-session%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            17














            Let's call the machine that has internet access hasinet and the one that doesn't noinet.



            If you can make an SSH connection from noinet to hasinet



            You can do this easily with OpenSSH's built-in SOCKS proxy. This command will set up a SOCKS proxy on noinet listening on port 1080:



            noinet$ ssh -D 1080 hasinet


            If you can only make SSH connections to noinet from hasinet



            You can run OpenSSH's SOCKS proxy on hasinet and then forward a port from noinet to hasinet. This can cleverly be done with one command like so (thanks @Patrick):



            hasinet$ ssh -D 1080 localhost -t ssh -R 1080:localhost:1080 noinet


            How to use the SOCKS proxy



            How you use this proxy will depend on the application. Some applications have support for SOCKS proxies built in. If that's the case, you'll need to configure your app to use the proxy on localhost:1080. If not, you can use proxychains or redsocks, as @sciurus suggests. tsocks is a lighter-weight solution if you only need to provide network access for some commands.






            share|improve this answer





















            • 1





              Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

              – Patrick
              Feb 26 '14 at 4:29













            • Oh yeah, that'll totally work. Thanks!

              – smammy
              Feb 27 '14 at 5:00
















            17














            Let's call the machine that has internet access hasinet and the one that doesn't noinet.



            If you can make an SSH connection from noinet to hasinet



            You can do this easily with OpenSSH's built-in SOCKS proxy. This command will set up a SOCKS proxy on noinet listening on port 1080:



            noinet$ ssh -D 1080 hasinet


            If you can only make SSH connections to noinet from hasinet



            You can run OpenSSH's SOCKS proxy on hasinet and then forward a port from noinet to hasinet. This can cleverly be done with one command like so (thanks @Patrick):



            hasinet$ ssh -D 1080 localhost -t ssh -R 1080:localhost:1080 noinet


            How to use the SOCKS proxy



            How you use this proxy will depend on the application. Some applications have support for SOCKS proxies built in. If that's the case, you'll need to configure your app to use the proxy on localhost:1080. If not, you can use proxychains or redsocks, as @sciurus suggests. tsocks is a lighter-weight solution if you only need to provide network access for some commands.






            share|improve this answer





















            • 1





              Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

              – Patrick
              Feb 26 '14 at 4:29













            • Oh yeah, that'll totally work. Thanks!

              – smammy
              Feb 27 '14 at 5:00














            17












            17








            17







            Let's call the machine that has internet access hasinet and the one that doesn't noinet.



            If you can make an SSH connection from noinet to hasinet



            You can do this easily with OpenSSH's built-in SOCKS proxy. This command will set up a SOCKS proxy on noinet listening on port 1080:



            noinet$ ssh -D 1080 hasinet


            If you can only make SSH connections to noinet from hasinet



            You can run OpenSSH's SOCKS proxy on hasinet and then forward a port from noinet to hasinet. This can cleverly be done with one command like so (thanks @Patrick):



            hasinet$ ssh -D 1080 localhost -t ssh -R 1080:localhost:1080 noinet


            How to use the SOCKS proxy



            How you use this proxy will depend on the application. Some applications have support for SOCKS proxies built in. If that's the case, you'll need to configure your app to use the proxy on localhost:1080. If not, you can use proxychains or redsocks, as @sciurus suggests. tsocks is a lighter-weight solution if you only need to provide network access for some commands.






            share|improve this answer















            Let's call the machine that has internet access hasinet and the one that doesn't noinet.



            If you can make an SSH connection from noinet to hasinet



            You can do this easily with OpenSSH's built-in SOCKS proxy. This command will set up a SOCKS proxy on noinet listening on port 1080:



            noinet$ ssh -D 1080 hasinet


            If you can only make SSH connections to noinet from hasinet



            You can run OpenSSH's SOCKS proxy on hasinet and then forward a port from noinet to hasinet. This can cleverly be done with one command like so (thanks @Patrick):



            hasinet$ ssh -D 1080 localhost -t ssh -R 1080:localhost:1080 noinet


            How to use the SOCKS proxy



            How you use this proxy will depend on the application. Some applications have support for SOCKS proxies built in. If that's the case, you'll need to configure your app to use the proxy on localhost:1080. If not, you can use proxychains or redsocks, as @sciurus suggests. tsocks is a lighter-weight solution if you only need to provide network access for some commands.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 27 '14 at 5:03

























            answered Feb 25 '14 at 17:40









            smammysmammy

            32614




            32614








            • 1





              Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

              – Patrick
              Feb 26 '14 at 4:29













            • Oh yeah, that'll totally work. Thanks!

              – smammy
              Feb 27 '14 at 5:00














            • 1





              Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

              – Patrick
              Feb 26 '14 at 4:29













            • Oh yeah, that'll totally work. Thanks!

              – smammy
              Feb 27 '14 at 5:00








            1




            1





            Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

            – Patrick
            Feb 26 '14 at 4:29







            Instead of having to install a socks proxy on hasinet when noinet needs to get out, just ssh -t -D 1080 localhost ssh -R 1080:localhost:1080 noinet (yes one command).

            – Patrick
            Feb 26 '14 at 4:29















            Oh yeah, that'll totally work. Thanks!

            – smammy
            Feb 27 '14 at 5:00





            Oh yeah, that'll totally work. Thanks!

            – smammy
            Feb 27 '14 at 5:00













            2














            Here's a way to do this via SSH:



            On the machine with no internet access, run



            ssh -D 8080 machine_with_internet_access


            You can replace 8080 with any unused port number,



            Then install software like proxychains or redsocks, configure them to connect to localhost:8080, and run software that needs internet access through them.






            share|improve this answer




























              2














              Here's a way to do this via SSH:



              On the machine with no internet access, run



              ssh -D 8080 machine_with_internet_access


              You can replace 8080 with any unused port number,



              Then install software like proxychains or redsocks, configure them to connect to localhost:8080, and run software that needs internet access through them.






              share|improve this answer


























                2












                2








                2







                Here's a way to do this via SSH:



                On the machine with no internet access, run



                ssh -D 8080 machine_with_internet_access


                You can replace 8080 with any unused port number,



                Then install software like proxychains or redsocks, configure them to connect to localhost:8080, and run software that needs internet access through them.






                share|improve this answer













                Here's a way to do this via SSH:



                On the machine with no internet access, run



                ssh -D 8080 machine_with_internet_access


                You can replace 8080 with any unused port number,



                Then install software like proxychains or redsocks, configure them to connect to localhost:8080, and run software that needs internet access through them.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 25 '14 at 16:20









                sciurussciurus

                25318




                25318






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f116867%2fserve-internet-to-remote-machine-via-ssh-session%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                    is 'sed' thread safe

                    How to make a Squid Proxy server?