http-Proxy über ssh, nicht socks

Die Frage ist einfach, aber die Antwort ist nicht :

ssh -D 8080 user@host

Oder

ssh -gCNf -D 8080 user@host

Oder

wathever with -D #

Ich brauche eine Art Proxy, den ich mit der Variablen http_proxy in einem eingebetteten Gerät verwenden kann, das SOCKS nicht unterstützt.

Was soll ich tun?

Author: behrooz, 2011-05-06

7 answers

Methode 1: Verwenden Sie einen HTTP-Proxy, der die Verwendung eines SOCKS-Upstream unterstützt, z. B. Polipo oder Privoxy.

Richten Sie zuerst wie immer einen -D Tunnel über SSH ein und konfigurieren Sie dann den HTTP-Proxy für die Verwendung des SSH-Tunnels-Beispiel Polipo-Konfiguration:

proxyAddress = "::1"
proxyPort = 8118
socksParentProxy = "localhost:8080"
socksProxyType = socks5

Zeigen Sie die App schließlich mit http_proxy=localhost:8118 auf Polipo.

Methode 2: Führen Sie Ihr Programm im torsocks - Wrapper (oder im älteren tsocks) aus, der alle Verbindungen transparent darstellt. Es war für die Verwendung mit Tor gedacht, aber funktioniert mit jedem SOCKS-server, einschließlich ssh -D.

Methode 3: Richten Sie einen HTTP-Proxy auf Ihrem Server ein und verwenden Sie dann ssh -L, um darauf zuzugreifen.

 40
Author: user1686,
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-19 13:28:14

Jedes -D ergibt einen SOCKS-Server. Wenn Ihr Client SOCKEN nicht verarbeiten kann, vergessen Sie -D.

Sie müssen einen HTTP-Proxy auf dem Remote-Host ausführen und mit -L weiterleiten:

ssh -f -N -n -L8080:127.0.0.1:8080 host
 21
Author: ceving,
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-11-15 14:43:06

Ich habe das gleiche Problem, das HTTP-Proxy über SSH verwenden möchte. Da viele Anwendungen nur HTTP-Proxy unterstützen, und HTTP-Proxy ist einfach in der Befehlszeilenumgebung verwendet werden.

Obwohl ich mehrere Seiten durchsucht habe, kann ich keinen direkten Weg finden(kann mit Polipo, Privoxy oder tsocks angekettet werden), dies zu tun...

Nach ein paar Tagen Arbeit habe ich eine einfache Golang-Version des HTTP-Proxys über SSH fertiggestellt. Fühlen Sie sich frei, damit zu spielen: mallory.

Derzeit nur unterstützung RSA schlüssel (befindet sich auf $HOME/.ssh/id_rsa) und Passwort Zulassung.

host ist die SSH-Serveradresse, port ist 22 wenn nicht von Ihrem Administrator geändert. Die Serverseite ist nur unser alter Freund sshd mit null Konfiguration.

mallory -engine=ssh -remote=ssh://host:port

Oder mit Benutzername user

mallory -engine=ssh -remote=ssh://user@host:port

Oder mit Benutzername user und Passwort 1234

mallory -engine=ssh -remote=ssh://user:1234@host:port

Nach der Verbindung wird ein HTTP-Proxy auf localhost:1315 bereitgestellt.

 8
Author: justmao945,
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
2014-06-19 12:54:47
ssh -L 8080:localhost:12345 user@host

Dadurch wird Port 8080 auf dem lokalen Computer geöffnet und alle Daten an Port 12345 auf localhost weitergeleitet, wie vom Remote-Computer aus gesehen.

 4
Author: lesmana,
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
2011-05-06 15:01:50

Führen Sie Privoxy auf dem Remote-Host aus und verbinden Sie sich dann über SSH mit Privoxy mit der Option -L:

-L [bind_address:]port:host:hostport
         Specifies that the given port on the local (client) host is to be
         forwarded to the given host and port on the remote side.  This
         works by allocating a socket to listen to port on the local side,
         optionally bound to the specified bind_address.  Whenever a con-
         nection is made to this port, the connection is forwarded over
         the secure channel, and a connection is made to host port
         hostport from the remote machine.

(manpage Quelle)

 2
Author: anonymous,
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-09-01 13:53:06

Sie können auch Korkenzieher (GPL)

Fügen Sie Folgendes zu Ihrem .ssh/config

Host=RemoteServerIP or Name
User=UserLoginName
Port=PortNumber
ProxCommand=/usr/bin/corkscrew Proxy.Adress PortNumber %h %p
 1
Author: aurelien,
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-11-15 15:28:55

Ausführlichere Anweisungen zur Verwendung von privoxy, all dies kann als eigener Benutzer ausgeführt werden.

Dadurch wird ein HTTP-Proxy bei 127.0.0.1:17470 erstellt, der auf dem Remote-ssh-Server beendet wird.

  1. Erstellen Sie einen Socks-Proxy bei 127.0.0.1:17471 mit ssh:

    ssh -f -NT -M -S ~/.ssh/ssh_socket-named-foobar -D 127.0.0.1:17471 remote-ssh-server
    
  2. Testen Sie den Socks-Proxy bei 127.0.0.1:17471 mit curl:

    curl --silent --proxy socks4a://127.0.0.1:17471 -4 https://checkip.amazonaws.com
    
  3. Erstellen privoxy config

    cat > ~/.config/privoxy-foobar.conf <<EOF
    listen-address  127.0.0.1:17470
    forward-socks4a / 127.0.0.1:17471 .
    EOF
    
  4. Starten Sie privoxy, das einen HTTP-Proxy bei 127.0.0.1:17470 erstellt, der den Socks-Proxy bei 127.0.0.1:17471

    privoxy --pidfile "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/privoxy-foobar.pid" ~/.config/privoxy-foobar.conf
    
  5. Testen Sie den HTTP-Proxy bei 127.0.0.1:17470 mit curl:

    curl --silent --proxy http://127.0.0.1:17470 -4 https://checkip.amazonaws.com
    
  6. Töte alles, wenn du fertig bist

    ssh -S ~/.ssh/ssh_socket-named-foobar -O exit example.com # hostname is ignored, so yes it is fine to put example.com
    kill "$(cat "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/privoxy-foobar.pid")"
    

Anmerkungen:

  • Sie möchten wahrscheinlich foobar in den Befehlen in einen Namen ändern, der für Sie sinnvoll ist, und mehrere Proxys mit solchen Namen ausführen.
 0
Author: Iwan Aucamp,
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-09-30 09:02:26