This is an old revision of the document!


SSH

Static Forwarding

Local forwarding:

ssh -L8021:<dist>:21 <host>

Remote forwarding (you need to set “GatewayPorts yes” in sshd_config if you want to access the port from other addresses than localhost, then “/etc/init.d/sshd reload”):

ssh -R8021:<dist>:21 <host>

Dynamic Forwarding

Use another machine as a proxy, turning localhost into a SOCKS proxy, eg on port 8080:

ssh -D8080 <host>

It may be a good idea to open a ssh server on a web port (80/8080/443), because you will need to use this when you have a restricted connection, and port 22 may be forbidden as well (just add Port 22 AND Port 80 to sshd_config, or configure NAT port forwarding on your router, and then use ssh -p <port> <host>…).

Then configure your apps to use it:

  • Firefox : Preferences | Advanced | Settings | Manual Proxy Configuration | SOCKS Host : localhost, Port : 8080
  • Thunderbird : Preferences | Advanced | Network & Disk space | Settings | Manual Proxy Configuration | SOCKS Host : localhost, Port : 8080
  • VLC : vlc –socks=“localhost:8080”
  • Pidgin : Tools | Preferences | Proxy | Proxy type: SOCKS 4, Host: localhost, Port: 8080
  • ssh, git, sshfs, scp, rsync : /etc/ssh_config
    # just to prevent from trying to use the proxy when you want to establish the proxy:
    Host <host>
        ProxyCommand socat STDIO TCP:%h:%p
    # for using the proxy for everything else:
    Host *
        ProxyCommand socat STDIO SOCKS4:localhost:%h:%p,socksport=8080
  • KDE apps (Konqueror, but does not work with Kopete…) ~/.kde4/share/config/kioslaverc
    [Proxy Settings]
    ProxyType=1
    socksProxy=socks://localhost:8080
  • Applications that do not support use of a proxy: configure tsocks in /etc/tsocks.conf:
    server = localhost
    server_type = 5
    server_port = 8080

    Then start your application with tsocks to force it to use the proxy:

    tsocks <app-with-args>
software/ssh.1339329864.txt.gz · Last modified: 2013/09/19 16:43 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0