Wie kann ich SSH mit einem SOCKS 5-Proxy verwenden?

Ich habe einen SOCKS5-Proxy über PuTTY eingerichtet, wobei Port 7777 als dynamischer Port konfiguriert ist. Ich kann Firefox / filezilla / etc verwenden, indem ich sie so konfiguriere, dass sie einen SOCKS-Proxy mit localhost und Port 7777. Ich kann jedoch nicht herausfinden, wie ssh (über Cygwin) mithilfe des dynamischen Ports zu einem Remote-Server geleitet wird. Ist das möglich?

Ich habe versucht, ProxyCommand über die folgende Methode zu verwenden.

  1. Erstelle ~/.ssh/config mit der folgenden Zeile:

    ProxyCommand /usr/bin/nc -X connect -x 127.0.0.1:7777 %h %p
    
  2. ssh-p22 ausführen benutzer@remotehost

Die Nachricht, die ich erhalte, ist ssh_exchange_identification: Connection closed by remote host

Author: Braiam, 2012-07-26

5 answers

Sie verwenden 'connect' für HTTPS als Proxy-Version, dies ist von man nc:

- X proxy_version fordert an, dass nc das angegebene Protokoll beim Gespräch mit dem Proxyserver verwenden soll. Unterstützte Protokolle sind" 4 "(SOCKS v. 4)," 5 "(SOCKS v. 5) und "connect" (HTTPS Proxy). Wenn das Protokoll nicht angegeben ist, wird SOCKS Version 5 verwendet.

Sie sollten also Folgendes verwenden, um SOCKS 5 zu verwenden:

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

Oder einfach:

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

Ich hoffe, es hilft.

 41
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2012-07-26 16:24:33
ssh -o ProxyCommand='nc --proxy-type socks4 --proxy 127.0.0.1:9050 %h %p' user@host

Fc19 x86_64, Ncat: Version 6.25

 13
Author: user264910,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2013-10-19 06:53:59

Tsocks (http://tsocks.sourceforge.net/) ist ein netter Wrapper, der LD_PRELOAD verwendet, um ein Programm SOCKS Proxy transparent zu machen:

tsocks ssh example.com

Funktioniert einfach, denken Sie daran, die SOCKS-Proxy-IP in /etc/tsocks zu konfigurieren.conf

 5
Author: neutrinus,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2016-05-23 08:30:40

Dieser folgende Befehl reicht aus, um nur nc zu verwenden:

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

Standard ist HTTP Proxy, auf Port 7000 läuft ein HTTP Proxy.

 1
Author: Chinglin Wen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2019-04-30 06:37:53

Nur um es einfacher zu machen, könnten Sie diese in ~/.ssh/config

host = example.com
ProxyCommand nc -X 5 -x 127.0.0.1:9150 %h %p

Jeder ssh-Befehl im Terminal wird nun diesen Proxy durchlaufen.

 0
Author: azerafati,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2020-10-02 08:22:02