2009-10-29 00:51:34 +0000 2009-10-29 00:51:34 +0000
120
120
Advertisement

Come posso instradare tutto il mio traffico di rete attraverso SSH?

Advertisement

Ogni volta che sto usando internet da un luogo insicuro (come un wifi pubblico) mi piace usare un tunnel ssh (ssh -D port host) per assicurarmi che il mio traffico non possa essere sniffato. Sfortunatamente, sembrano esserci molte applicazioni che non forniscono un modo per specificare un proxy (Flash è un esempio importante).

Sembra che ci dovrebbe essere un modo per usare un tunnel per tutto il traffico di rete dal mio computer, ma sono completamente ignorante su come farlo. Qualsiasi aiuto sarebbe molto apprezzato.

Advertisement
Advertisement

Risposte (7)

65
65
65
2014-05-23 16:08:57 +0000

Per fare quello che volete, vi consiglio sshuttle .

Lo usi in questo modo:

./sshuttle -r username@sshserver 0.0.0.0/0 -vv

Tunnelerà tutto il tuo traffico TCP automaticamente per te. Puoi aggiungere l'argomento --dns per fargli fare un tunnel anche al tuo traffico DNS. Il server remoto ha solo bisogno di avere Python installato.

Se vuoi fare il tunnel solo per programmi specifici, raccomanderei proxychains .

Una volta installato, avviate il vostro ssh socks proxy in questo modo:

ssh -fNTD 127.0.0.1:<local port> username@sshserver

Questo avvierà un proxy “SOCKS” in ascolto su <porta locale>.

Poi modifica /etc/proxychains.conf per puntare alla stessa porta di <porta locale>.

Infine avvia il tuo programma che vuoi proxy-ed in questo modo:

proxychains <program name>

Dovrebbe funzionare. Tuttavia, alcuni programmi avranno problemi a lavorare con le catene di proxy. Tieni anche presente che con Firefox, devi cambiare altri elementi sotto about:config per forzarlo a fare le ricerche DNS attraverso il proxy invece di bypassarlo.

Come nota aggiuntiva, sui browser web. Se supportano i proxy socks, non c'è bisogno di fare nulla di aggiuntivo per fargli usare il tunnel ssh di cui sopra, basta inserire 127.0.0.1 per il server proxy SOCKS e la <porta locale> per la porta del proxy.

EDIT 3/29/16

Visto che questo post sta ancora vedendo alcuni upvotes, ho pensato di aggiornarlo. Proxychains è ancora nella maggior parte dei repo di Linux e funziona ancora su Linux. Tuttavia, il progetto è effettivamente abbandonato e non funziona su OSX. Sia per Linux che per OSX, raccomando vivamente di passare ad un fork ancora mantenuto: proxychains-ng: https://github.com/rofl0r/proxychains-ng

Oltre a funzionare sia in Linux che in OSX, è facile da compilare e ha anche un supporto molto migliore per il tunneling DNS.

Dovrei anche menzionare un'altra opzione, che è redsocks. Funziona in modo simile a proxychains(-ng) ed è anche probabile che sia nella vostra dist repo: https://github.com/darkk/redsocks

EDIT 11/27/19 Se scegliete il percorso proxychains, per favore usate proxychains-ng. Ci sono alcune serie correzioni di bug rispetto alla versione legacy, come: https://github.com/rofl0r/proxychains-ng/issues/292

50
50
50
2011-07-18 10:24:01 +0000

man ssh dà un esempio proprio di questo. Una vpn basata su ssh:

SSH-BASED VIRTUAL PRIVATE NETWORKS
     ssh contains support for Virtual Private Network (VPN) tunnelling using
     the tun(4) network pseudo-device, allowing two networks to be joined
     securely. The sshd_config(5) configuration option PermitTunnel controls
     whether the server supports this, and at what level (layer 2 or 3 traf-
     fic).

     The following example would connect client network 10.0.50.0/24 with
     remote network 10.0.99.0/24, provided that the SSH server running on the
     gateway to the remote network, at 192.168.1.15, allows it:

       # ssh -f -w 0:1 192.168.1.15 true
       # ifconfig tun0 10.0.50.1 10.0.99.1 netmask 255.255.255.252

snip~

Since a SSH-based setup entails a fair amount of overhead, it may be more
     suited to temporary setups, such as for wireless VPNs. More permanent
     VPNs are better provided by tools such as ipsecctl(8) and isakmpd(8).

Una volta che avete questa nuova interfaccia, dovreste solo renderla la rotta predefinita, che è una domanda diversa.

6
Advertisement
6
6
2009-11-01 17:40:29 +0000
Advertisement

Cercate l'opzione “Tunnel” in ssh. Questo crea un dispositivo tunnel a cui puoi assegnare un indirizzo IP, e poi cambi il percorso predefinito per usare quel tunnel.

4
4
4
2011-07-18 08:55:38 +0000

Ho sviluppato un software che permette di inoltrare tutti i TCP e opzionalmente UDP attraverso un proxy SOCKS5, a livello di sistema. http://code.google.com/p/badvpn/wiki/tun2socks

Può anche essere installato su un router per inoltrare tutte le connessioni dai computer della LAN.

0
Advertisement
0
0
2013-03-12 22:57:21 +0000
Advertisement

SSH-BASED VIRTUAL PRIVATE NETWORKS ssh contiene il supporto per il tunnelling di Virtual Private Network (VPN) usando lo pseudo-dispositivo di rete tun(4), permettendo a due reti di essere unite in modo sicuro. L'opzione di configurazione sshd\config(5) PermitTunnel controlla se il server supporta questo, e a quale livello (layer 2 o 3 traf- fic).

The following example would connect client network 10.0.50.0/24 with
 remote network 10.0.99.0/24 using a point-to-point connection from
 10.1.1.1 to 10.1.1.2, provided that the SSH server running on the gateway
 to the remote network, at 192.168.1.15, allows it.

 On the client:

       # ssh -f -w 0:1 192.168.1.15 true
       # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
       # route add 10.0.99.0/24 10.1.1.2

 On the server:

       # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
       # route add 10.0.50.0/24 10.1.1.1

 Client access may be more finely tuned via the /root/.ssh/authorized_keys
 file (see below) and the PermitRootLogin server option. The following
 entry would permit connections on tun(4) device 1 from user “jane” and on
 tun device 2 from user “john”, if PermitRootLogin is set to
 “forced-commands-only”:

   tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
   tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john

 Since an SSH-based setup entails a fair amount of overhead, it may be
 more suited to temporary setups, such as for wireless VPNs. More perma‐
 nent VPNs are better provided by tools such as ipsecctl(8) and
 isakmpd(8).
-2
-2
-2
2009-10-29 01:43:30 +0000

Volevo solo chiarire che (ssh -D port host) non è un modo sicuro al 100% per evitare che il traffico venga sniffato. Aggiungere (ssh -D -c blowfish port host) sarebbe una scelta migliore perché state almeno aggiungendo la crittografia alla vostra sessione. Ci sono altre opzioni che potreste aggiungere, ma è abbastanza facile digitare “man ssh” nel vostro terminale o su Google per un elenco completo.

L'opzione che penso tu stia cercando è la creazione di una VPN (Virtual Private Network)

Dai un'occhiata a questo articolo per capire la differenza tra i due SSH vs. VPN ) o una buona versione riassuntiva , prima di affrontare la creazione della tua VPN. Se decidi di prendere la strada della VPN ti consiglio OpenVPN , è gratuita e ha molta documentazione e supporto.

-3
Advertisement
-3
-3
2009-11-01 17:47:59 +0000
Advertisement

Usate questi esempi:

  • Inoltrare la porta 80 da un host remoto alla 8888 sul tuo localhost

  • Inoltrare la porta 80 dal tuo localhost alla 8888 su un host remoto

Salute! :)

Advertisement

Domande correlate

6
10
19
12
4
Advertisement