How can I use SSH with a SOCKS 5 proxy?











up vote
27
down vote

favorite
10












I have a SOCKS5 proxy set up through PuTTY with port 7777 configured as a dynamic port. I can use firefox/filezilla/etc by configuring them to use a SOCKS proxy with localhost and port 7777. But I can't figure out how to ssh (through Cygwin) to a remote server by using the dynamic port. Is this possible?



I've tried using ProxyCommand via the following method.





  1. Create ~/.ssh/config with the following line:



    ProxyCommand /usr/bin/nc -X connect -x 127.0.0.1:7777 %h %p


  2. Run ssh -p22 user@remotehost


The message I get is ssh_exchange_identification: Connection closed by remote host










share|improve this question















migrated from stackoverflow.com Jul 27 '12 at 4:22


This question came from our site for professional and enthusiast programmers.











  • 1




    To make a program whuch does not support SOCKS go through SOCKS, you can use a so-called proxifer; see en.wikipedia.org/wiki/Comparison_of_proxifiers . In particular, I recommand my open source tun2socks proxifer ( code.google.com/p/badvpn/wiki/tun2socks ).
    – Ambroz Bizjak
    Jul 26 '12 at 15:34










  • Thanks for the comment Ambroz. I need it to work in cygwin, and I see from the wikipedia page on proxifiers that all of the ones it mentions are either not implemented in cygwin or not applicable. Is there a way to get a proxifier to work in cygwin?
    – Rusty Lemur
    Jul 26 '12 at 15:41










  • you don't need it to specifically support Cygwin. Cygwin programs are in the end just Windows programs, but with a POSIX interface implemented as a library. If a proxifier works on Windows, it should be able to proxify Cygwin programs just fine.
    – Ambroz Bizjak
    Jul 26 '12 at 16:50















up vote
27
down vote

favorite
10












I have a SOCKS5 proxy set up through PuTTY with port 7777 configured as a dynamic port. I can use firefox/filezilla/etc by configuring them to use a SOCKS proxy with localhost and port 7777. But I can't figure out how to ssh (through Cygwin) to a remote server by using the dynamic port. Is this possible?



I've tried using ProxyCommand via the following method.





  1. Create ~/.ssh/config with the following line:



    ProxyCommand /usr/bin/nc -X connect -x 127.0.0.1:7777 %h %p


  2. Run ssh -p22 user@remotehost


The message I get is ssh_exchange_identification: Connection closed by remote host










share|improve this question















migrated from stackoverflow.com Jul 27 '12 at 4:22


This question came from our site for professional and enthusiast programmers.











  • 1




    To make a program whuch does not support SOCKS go through SOCKS, you can use a so-called proxifer; see en.wikipedia.org/wiki/Comparison_of_proxifiers . In particular, I recommand my open source tun2socks proxifer ( code.google.com/p/badvpn/wiki/tun2socks ).
    – Ambroz Bizjak
    Jul 26 '12 at 15:34










  • Thanks for the comment Ambroz. I need it to work in cygwin, and I see from the wikipedia page on proxifiers that all of the ones it mentions are either not implemented in cygwin or not applicable. Is there a way to get a proxifier to work in cygwin?
    – Rusty Lemur
    Jul 26 '12 at 15:41










  • you don't need it to specifically support Cygwin. Cygwin programs are in the end just Windows programs, but with a POSIX interface implemented as a library. If a proxifier works on Windows, it should be able to proxify Cygwin programs just fine.
    – Ambroz Bizjak
    Jul 26 '12 at 16:50













up vote
27
down vote

favorite
10









up vote
27
down vote

favorite
10






10





I have a SOCKS5 proxy set up through PuTTY with port 7777 configured as a dynamic port. I can use firefox/filezilla/etc by configuring them to use a SOCKS proxy with localhost and port 7777. But I can't figure out how to ssh (through Cygwin) to a remote server by using the dynamic port. Is this possible?



I've tried using ProxyCommand via the following method.





  1. Create ~/.ssh/config with the following line:



    ProxyCommand /usr/bin/nc -X connect -x 127.0.0.1:7777 %h %p


  2. Run ssh -p22 user@remotehost


The message I get is ssh_exchange_identification: Connection closed by remote host










share|improve this question















I have a SOCKS5 proxy set up through PuTTY with port 7777 configured as a dynamic port. I can use firefox/filezilla/etc by configuring them to use a SOCKS proxy with localhost and port 7777. But I can't figure out how to ssh (through Cygwin) to a remote server by using the dynamic port. Is this possible?



I've tried using ProxyCommand via the following method.





  1. Create ~/.ssh/config with the following line:



    ProxyCommand /usr/bin/nc -X connect -x 127.0.0.1:7777 %h %p


  2. Run ssh -p22 user@remotehost


The message I get is ssh_exchange_identification: Connection closed by remote host







linux proxy ssh cygwin socks






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '17 at 16:45









Braiam

3,99631851




3,99631851










asked Jul 26 '12 at 15:09









Rusty Lemur

256136




256136




migrated from stackoverflow.com Jul 27 '12 at 4:22


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Jul 27 '12 at 4:22


This question came from our site for professional and enthusiast programmers.










  • 1




    To make a program whuch does not support SOCKS go through SOCKS, you can use a so-called proxifer; see en.wikipedia.org/wiki/Comparison_of_proxifiers . In particular, I recommand my open source tun2socks proxifer ( code.google.com/p/badvpn/wiki/tun2socks ).
    – Ambroz Bizjak
    Jul 26 '12 at 15:34










  • Thanks for the comment Ambroz. I need it to work in cygwin, and I see from the wikipedia page on proxifiers that all of the ones it mentions are either not implemented in cygwin or not applicable. Is there a way to get a proxifier to work in cygwin?
    – Rusty Lemur
    Jul 26 '12 at 15:41










  • you don't need it to specifically support Cygwin. Cygwin programs are in the end just Windows programs, but with a POSIX interface implemented as a library. If a proxifier works on Windows, it should be able to proxify Cygwin programs just fine.
    – Ambroz Bizjak
    Jul 26 '12 at 16:50














  • 1




    To make a program whuch does not support SOCKS go through SOCKS, you can use a so-called proxifer; see en.wikipedia.org/wiki/Comparison_of_proxifiers . In particular, I recommand my open source tun2socks proxifer ( code.google.com/p/badvpn/wiki/tun2socks ).
    – Ambroz Bizjak
    Jul 26 '12 at 15:34










  • Thanks for the comment Ambroz. I need it to work in cygwin, and I see from the wikipedia page on proxifiers that all of the ones it mentions are either not implemented in cygwin or not applicable. Is there a way to get a proxifier to work in cygwin?
    – Rusty Lemur
    Jul 26 '12 at 15:41










  • you don't need it to specifically support Cygwin. Cygwin programs are in the end just Windows programs, but with a POSIX interface implemented as a library. If a proxifier works on Windows, it should be able to proxify Cygwin programs just fine.
    – Ambroz Bizjak
    Jul 26 '12 at 16:50








1




1




To make a program whuch does not support SOCKS go through SOCKS, you can use a so-called proxifer; see en.wikipedia.org/wiki/Comparison_of_proxifiers . In particular, I recommand my open source tun2socks proxifer ( code.google.com/p/badvpn/wiki/tun2socks ).
– Ambroz Bizjak
Jul 26 '12 at 15:34




To make a program whuch does not support SOCKS go through SOCKS, you can use a so-called proxifer; see en.wikipedia.org/wiki/Comparison_of_proxifiers . In particular, I recommand my open source tun2socks proxifer ( code.google.com/p/badvpn/wiki/tun2socks ).
– Ambroz Bizjak
Jul 26 '12 at 15:34












Thanks for the comment Ambroz. I need it to work in cygwin, and I see from the wikipedia page on proxifiers that all of the ones it mentions are either not implemented in cygwin or not applicable. Is there a way to get a proxifier to work in cygwin?
– Rusty Lemur
Jul 26 '12 at 15:41




Thanks for the comment Ambroz. I need it to work in cygwin, and I see from the wikipedia page on proxifiers that all of the ones it mentions are either not implemented in cygwin or not applicable. Is there a way to get a proxifier to work in cygwin?
– Rusty Lemur
Jul 26 '12 at 15:41












you don't need it to specifically support Cygwin. Cygwin programs are in the end just Windows programs, but with a POSIX interface implemented as a library. If a proxifier works on Windows, it should be able to proxify Cygwin programs just fine.
– Ambroz Bizjak
Jul 26 '12 at 16:50




you don't need it to specifically support Cygwin. Cygwin programs are in the end just Windows programs, but with a POSIX interface implemented as a library. If a proxifier works on Windows, it should be able to proxify Cygwin programs just fine.
– Ambroz Bizjak
Jul 26 '12 at 16:50










4 Answers
4






active

oldest

votes

















up vote
26
down vote



accepted










You are using 'connect' for HTTPS as your proxy version, this is from man nc:




-X proxy_version Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are ''4'' (SOCKS v.4), ''5'' (SOCKS v.5) and 'connect' (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.




So you should use the following to use SOCKS 5:



ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:7777 %h %p


Or simply:



ProxyCommand /usr/bin/nc -x 127.0.0.1:7777 %h %p


I hope it helps.






share|improve this answer





















  • Thanks Saman, that worked! Also, thanks for the explanation, it helps.
    – Rusty Lemur
    Jul 26 '12 at 18:19










  • The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
    – Aaron McDaid
    Jul 14 '16 at 19:21










  • @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
    – mpb
    Jun 26 '17 at 2:41










  • Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
    – Per Lundberg
    May 18 at 10:25


















up vote
10
down vote













ssh -o ProxyCommand='nc --proxy-type socks4 --proxy 127.0.0.1:9050 %h %p' user@host


fc19 x86_64, Ncat: Version 6.25






share|improve this answer





















  • just curious - why proxy-type socks4?
    – suspectus
    Oct 19 '13 at 9:57






  • 2




    Can you add a little more explanation to this to say why it's the solution.
    – ChrisF
    Oct 19 '13 at 10:48






  • 1




    @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
    – j123b567
    Dec 2 '15 at 9:39






  • 1




    This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
    – Adam Katz
    Nov 5 '16 at 0:07








  • 1




    @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
    – Randall
    Nov 27 '17 at 16:09


















up vote
3
down vote













tsocks (http://tsocks.sourceforge.net/) is a nice wrapper that uses LD_PRELOAD to make any program use SOCKS proxy transparently:



tsocks ssh example.com


Just works, remember to configure SOCKS proxy IP in /etc/tsocks.conf






share|improve this answer





















  • it's too complex to have a configuration file
    – Jiang YD
    Mar 14 '17 at 3:10


















up vote
0
down vote













this following command will do, to just use nc.




ssh examplehost.com -o "ProxyCommand=nc --proxy localhost:7000 %h %p"



default is http proxy, there is an http proxy running on port 7000.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fsuperuser.com%2fquestions%2f454210%2fhow-can-i-use-ssh-with-a-socks-5-proxy%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    26
    down vote



    accepted










    You are using 'connect' for HTTPS as your proxy version, this is from man nc:




    -X proxy_version Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are ''4'' (SOCKS v.4), ''5'' (SOCKS v.5) and 'connect' (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.




    So you should use the following to use SOCKS 5:



    ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:7777 %h %p


    Or simply:



    ProxyCommand /usr/bin/nc -x 127.0.0.1:7777 %h %p


    I hope it helps.






    share|improve this answer





















    • Thanks Saman, that worked! Also, thanks for the explanation, it helps.
      – Rusty Lemur
      Jul 26 '12 at 18:19










    • The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
      – Aaron McDaid
      Jul 14 '16 at 19:21










    • @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
      – mpb
      Jun 26 '17 at 2:41










    • Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
      – Per Lundberg
      May 18 at 10:25















    up vote
    26
    down vote



    accepted










    You are using 'connect' for HTTPS as your proxy version, this is from man nc:




    -X proxy_version Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are ''4'' (SOCKS v.4), ''5'' (SOCKS v.5) and 'connect' (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.




    So you should use the following to use SOCKS 5:



    ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:7777 %h %p


    Or simply:



    ProxyCommand /usr/bin/nc -x 127.0.0.1:7777 %h %p


    I hope it helps.






    share|improve this answer





















    • Thanks Saman, that worked! Also, thanks for the explanation, it helps.
      – Rusty Lemur
      Jul 26 '12 at 18:19










    • The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
      – Aaron McDaid
      Jul 14 '16 at 19:21










    • @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
      – mpb
      Jun 26 '17 at 2:41










    • Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
      – Per Lundberg
      May 18 at 10:25













    up vote
    26
    down vote



    accepted







    up vote
    26
    down vote



    accepted






    You are using 'connect' for HTTPS as your proxy version, this is from man nc:




    -X proxy_version Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are ''4'' (SOCKS v.4), ''5'' (SOCKS v.5) and 'connect' (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.




    So you should use the following to use SOCKS 5:



    ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:7777 %h %p


    Or simply:



    ProxyCommand /usr/bin/nc -x 127.0.0.1:7777 %h %p


    I hope it helps.






    share|improve this answer












    You are using 'connect' for HTTPS as your proxy version, this is from man nc:




    -X proxy_version Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are ''4'' (SOCKS v.4), ''5'' (SOCKS v.5) and 'connect' (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.




    So you should use the following to use SOCKS 5:



    ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:7777 %h %p


    Or simply:



    ProxyCommand /usr/bin/nc -x 127.0.0.1:7777 %h %p


    I hope it helps.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 26 '12 at 16:24







    Saman Barghi



















    • Thanks Saman, that worked! Also, thanks for the explanation, it helps.
      – Rusty Lemur
      Jul 26 '12 at 18:19










    • The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
      – Aaron McDaid
      Jul 14 '16 at 19:21










    • @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
      – mpb
      Jun 26 '17 at 2:41










    • Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
      – Per Lundberg
      May 18 at 10:25


















    • Thanks Saman, that worked! Also, thanks for the explanation, it helps.
      – Rusty Lemur
      Jul 26 '12 at 18:19










    • The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
      – Aaron McDaid
      Jul 14 '16 at 19:21










    • @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
      – mpb
      Jun 26 '17 at 2:41










    • Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
      – Per Lundberg
      May 18 at 10:25
















    Thanks Saman, that worked! Also, thanks for the explanation, it helps.
    – Rusty Lemur
    Jul 26 '12 at 18:19




    Thanks Saman, that worked! Also, thanks for the explanation, it helps.
    – Rusty Lemur
    Jul 26 '12 at 18:19












    The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
    – Aaron McDaid
    Jul 14 '16 at 19:21




    The ProxyCommand must be the first line of your ~/.ssh/config', or else nested inside a specify Host` section. Not really sure why. It doesn't work if it's the last line in the ~/.ssh/config
    – Aaron McDaid
    Jul 14 '16 at 19:21












    @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
    – mpb
    Jun 26 '17 at 2:41




    @AaronMcDaid: From man ssh_config: "For each parameter, the first obtained value will be used." Therefore... global settings need to be before any Host sections. The last line of ~/.ssh/config is part of the final Host section.
    – mpb
    Jun 26 '17 at 2:41












    Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
    – Per Lundberg
    May 18 at 10:25




    Worth mentioning is that netcat is in /bin/nc on Debian and Ubuntu.
    – Per Lundberg
    May 18 at 10:25












    up vote
    10
    down vote













    ssh -o ProxyCommand='nc --proxy-type socks4 --proxy 127.0.0.1:9050 %h %p' user@host


    fc19 x86_64, Ncat: Version 6.25






    share|improve this answer





















    • just curious - why proxy-type socks4?
      – suspectus
      Oct 19 '13 at 9:57






    • 2




      Can you add a little more explanation to this to say why it's the solution.
      – ChrisF
      Oct 19 '13 at 10:48






    • 1




      @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
      – j123b567
      Dec 2 '15 at 9:39






    • 1




      This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
      – Adam Katz
      Nov 5 '16 at 0:07








    • 1




      @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
      – Randall
      Nov 27 '17 at 16:09















    up vote
    10
    down vote













    ssh -o ProxyCommand='nc --proxy-type socks4 --proxy 127.0.0.1:9050 %h %p' user@host


    fc19 x86_64, Ncat: Version 6.25






    share|improve this answer





















    • just curious - why proxy-type socks4?
      – suspectus
      Oct 19 '13 at 9:57






    • 2




      Can you add a little more explanation to this to say why it's the solution.
      – ChrisF
      Oct 19 '13 at 10:48






    • 1




      @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
      – j123b567
      Dec 2 '15 at 9:39






    • 1




      This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
      – Adam Katz
      Nov 5 '16 at 0:07








    • 1




      @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
      – Randall
      Nov 27 '17 at 16:09













    up vote
    10
    down vote










    up vote
    10
    down vote









    ssh -o ProxyCommand='nc --proxy-type socks4 --proxy 127.0.0.1:9050 %h %p' user@host


    fc19 x86_64, Ncat: Version 6.25






    share|improve this answer












    ssh -o ProxyCommand='nc --proxy-type socks4 --proxy 127.0.0.1:9050 %h %p' user@host


    fc19 x86_64, Ncat: Version 6.25







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 19 '13 at 6:53









    user264910

    10112




    10112












    • just curious - why proxy-type socks4?
      – suspectus
      Oct 19 '13 at 9:57






    • 2




      Can you add a little more explanation to this to say why it's the solution.
      – ChrisF
      Oct 19 '13 at 10:48






    • 1




      @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
      – j123b567
      Dec 2 '15 at 9:39






    • 1




      This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
      – Adam Katz
      Nov 5 '16 at 0:07








    • 1




      @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
      – Randall
      Nov 27 '17 at 16:09


















    • just curious - why proxy-type socks4?
      – suspectus
      Oct 19 '13 at 9:57






    • 2




      Can you add a little more explanation to this to say why it's the solution.
      – ChrisF
      Oct 19 '13 at 10:48






    • 1




      @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
      – j123b567
      Dec 2 '15 at 9:39






    • 1




      This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
      – Adam Katz
      Nov 5 '16 at 0:07








    • 1




      @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
      – Randall
      Nov 27 '17 at 16:09
















    just curious - why proxy-type socks4?
    – suspectus
    Oct 19 '13 at 9:57




    just curious - why proxy-type socks4?
    – suspectus
    Oct 19 '13 at 9:57




    2




    2




    Can you add a little more explanation to this to say why it's the solution.
    – ChrisF
    Oct 19 '13 at 10:48




    Can you add a little more explanation to this to say why it's the solution.
    – ChrisF
    Oct 19 '13 at 10:48




    1




    1




    @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
    – j123b567
    Dec 2 '15 at 9:39




    @ChrisF it is the same as accepted solution, but it is one-liner! No need to modify any config file.
    – j123b567
    Dec 2 '15 at 9:39




    1




    1




    This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
    – Adam Katz
    Nov 5 '16 at 0:07






    This is the nmap ncat program (comes via apt install nmap on APT systems like Ubuntu and Debian), which is different from netcat (be it netcat-openbsd or Hobbit's netcat-traditional).
    – Adam Katz
    Nov 5 '16 at 0:07






    1




    1




    @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
    – Randall
    Nov 27 '17 at 16:09




    @suspectus related to @Adam Katz comment, the proxy-type is socks4 because the nmap ncat program didn't support sock5 until more recently. Indeed, this is an issue even now (Nov 2017), as RHEL 7/Centos 7 switched to the nmap package but used an older build that does not support socks5
    – Randall
    Nov 27 '17 at 16:09










    up vote
    3
    down vote













    tsocks (http://tsocks.sourceforge.net/) is a nice wrapper that uses LD_PRELOAD to make any program use SOCKS proxy transparently:



    tsocks ssh example.com


    Just works, remember to configure SOCKS proxy IP in /etc/tsocks.conf






    share|improve this answer





















    • it's too complex to have a configuration file
      – Jiang YD
      Mar 14 '17 at 3:10















    up vote
    3
    down vote













    tsocks (http://tsocks.sourceforge.net/) is a nice wrapper that uses LD_PRELOAD to make any program use SOCKS proxy transparently:



    tsocks ssh example.com


    Just works, remember to configure SOCKS proxy IP in /etc/tsocks.conf






    share|improve this answer





















    • it's too complex to have a configuration file
      – Jiang YD
      Mar 14 '17 at 3:10













    up vote
    3
    down vote










    up vote
    3
    down vote









    tsocks (http://tsocks.sourceforge.net/) is a nice wrapper that uses LD_PRELOAD to make any program use SOCKS proxy transparently:



    tsocks ssh example.com


    Just works, remember to configure SOCKS proxy IP in /etc/tsocks.conf






    share|improve this answer












    tsocks (http://tsocks.sourceforge.net/) is a nice wrapper that uses LD_PRELOAD to make any program use SOCKS proxy transparently:



    tsocks ssh example.com


    Just works, remember to configure SOCKS proxy IP in /etc/tsocks.conf







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered May 23 '16 at 8:30









    neutrinus

    1393




    1393












    • it's too complex to have a configuration file
      – Jiang YD
      Mar 14 '17 at 3:10


















    • it's too complex to have a configuration file
      – Jiang YD
      Mar 14 '17 at 3:10
















    it's too complex to have a configuration file
    – Jiang YD
    Mar 14 '17 at 3:10




    it's too complex to have a configuration file
    – Jiang YD
    Mar 14 '17 at 3:10










    up vote
    0
    down vote













    this following command will do, to just use nc.




    ssh examplehost.com -o "ProxyCommand=nc --proxy localhost:7000 %h %p"



    default is http proxy, there is an http proxy running on port 7000.






    share|improve this answer

























      up vote
      0
      down vote













      this following command will do, to just use nc.




      ssh examplehost.com -o "ProxyCommand=nc --proxy localhost:7000 %h %p"



      default is http proxy, there is an http proxy running on port 7000.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        this following command will do, to just use nc.




        ssh examplehost.com -o "ProxyCommand=nc --proxy localhost:7000 %h %p"



        default is http proxy, there is an http proxy running on port 7000.






        share|improve this answer












        this following command will do, to just use nc.




        ssh examplehost.com -o "ProxyCommand=nc --proxy localhost:7000 %h %p"



        default is http proxy, there is an http proxy running on port 7000.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 9:58









        Chinglin Wen

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fsuperuser.com%2fquestions%2f454210%2fhow-can-i-use-ssh-with-a-socks-5-proxy%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

            QoS: MAC-Priority for clients behind a repeater

            Ивакино (Тотемский район)

            Can't locate Autom4te/ChannelDefs.pm in @INC (when it definitely is there)