Ssh/tunnel

Aus SchnallIchNet
< Ssh
Version vom 4. Juni 2018, 08:43 Uhr von Cbs (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

socks proxy

ssh enables me to simply create an ssh-tunnel which provides a socks proxy.
this is really simple!
ssh protocoll version 2 is needed but should prefered anyway... ;-)

ssh [-f] -N -D[ip:]1080 <username>@my.sshenabled.really.huge.bandwith.connected.host.tld

where:

  • -f run in background, otherwise ssh runs in foreground...
  • -N says sshd not to start any application on destination host
  • -D specifies the port to use on the local host (1080)
    • if you do not specify an IP of your local system, localhost (127.0.0.1) is used...
    • keep in mind, that you need to be root to allocate well-known-ports


.ssh/config:

DynamicForward 127.0.0.1:1080

or

Host proxy
        Hostname 10.21.22.23
        User <user>
        Protocol 2
        DynamicForward 4711

now do:

ssh proxy

and then:

ssh -o ProxyCommand="/usr/bin/nc --proxy 127.0.0.1:4711 --proxy-type socks4 %h %p" ws01.domain.tld -l root


Local forward

der sshclient 10.10.11.254 wird mein zugriff auf den lokalen port 3389 durch den ssh-server 213.221.106.43 auf das zielsystem 192.168.102.50:3389 weitergeleitet.


beispiel:
=========
csteidl@koblenz$
ssh -L 10.10.11.254:3389:192.168.102.50:3389 -f -N root@213.221.106.43

~/.ssh/config:
--------------
LocalForward 10.10.11.254:3389 192.168.102.50:3389


allgemeine syntax:
==================
ssh -L [lokaler_host:]lokaler_port:dst_host:dst_port -f -N user@ssh_host

erklaerung:
===========
beim aufbau eine remotedesktop verbindung an 10.10.11.254:3389 wird dann die 
verbindung von 213.221.106.43 (192.168.102.40) an 192.168.102.50:3389 
weitergeleitet, wobei _nur_ der server 213.221.106.43 verbindung zum server 
192.168.102.50 hat. 

koblenz              ssh_host (NAT)                      ssh_host (real)
10.10.11.254 ---> FW:213.221.106.43:22 ---|1:1 nat|---> 192.168.102.40:22
                                                               |
                                                               |
                                                              3389
                                                               |
                                                               |
                                                               v
                                                          192.168.102.50 (win) 
                                                            dst_host


Remote Forward

der ssh-server 213.221.106.43 kann durch connect auf 127.0.0.1:8000 auf den port 80 des ssh-client 10.10.11.254 zugreifen

ssh -R 127.0.0.1:8000:10.10.11.254:80 213.221.106.43


~/.ssh/config:

RemoteForward 127.0.0.1:8000 10.10.11.254:80