documentazione_3di_riservata:manuali_sysadmin:openvpnautossh
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
documentazione_3di_riservata:manuali_sysadmin:openvpnautossh [2016/04/01 10:18] – vpascali | documentazione_3di_riservata:manuali_sysadmin:openvpnautossh [Data sconosciuta] (versione attuale) – eliminata - modifica esterna (Data sconosciuta) 127.0.0.1 | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
- | === abilito il login da root sulla vm da console === | ||
- | < | ||
- | sed -i s/ | ||
- | </ | ||
- | ===Installo il software=== | ||
- | Per installare i servizi necessari lanciare il comando | ||
- | < | ||
- | apt-get install openvpn autossh -y | ||
- | </ | ||
- | |||
- | **OPENVPN: | ||
- | |||
- | Presupponendo presente sulla vm la cartella Vpn con all' | ||
- | |||
- | < | ||
- | cp -rv / | ||
- | cp / | ||
- | systemctl daemon-reload | ||
- | </ | ||
- | |||
- | vim / | ||
- | |||
- | < | ||
- | [Unit] | ||
- | Description=OpenVPN connection to %i | ||
- | PartOf=openvpn.service | ||
- | ReloadPropagatedFrom=openvpn.service | ||
- | |||
- | [Service] | ||
- | Type=forking | ||
- | ExecStart=/ | ||
- | ExecReload=/ | ||
- | WorkingDirectory=/ | ||
- | |||
- | [Install] | ||
- | WantedBy=multi-user.target | ||
- | </ | ||
- | |||
- | |||
- | **Abilito il servizio all' | ||
- | < | ||
- | systemctl enable openvpn@apv.service | ||
- | </ | ||
- | **AUTOSSH: | ||
- | |||
- | **aggiungo l' | ||
- | < | ||
- | useradd -m -s /bin/false autossh | ||
- | </ | ||
- | |||
- | *** creo il file config di ssh (esempio preso da apv): *** | ||
- | < | ||
- | Host autportven-prod | ||
- | HostName 10.0.20.30 | ||
- | Port 22 | ||
- | User extraway | ||
- | Localforward 8080 localhost: | ||
- | Localforward 5432 localhost: | ||
- | Localforward 19080 10.0.20.31: | ||
- | Localforward 13306 10.0.20.31: | ||
- | </ | ||
- | |||
- | **creo le chiavi:** | ||
- | < | ||
- | su -s /bin/bash autossh | ||
- | ssh-keygen -t rsa | ||
- | </ | ||
- | |||
- | **copio le chiavi sul server prod del cliente:** | ||
- | |||
- | scp id_rsa.pub extraway@10.0.20.30:/ | ||
- | |||
- | **aggiungo in coda la chiave fra quelle autorizzate: | ||
- | |||
- | cat / | ||
- | |||
- | **cancello la chiave copiata:** | ||
- | |||
- | rm -f / | ||
- | |||
- | **configuro il mapping delle porte ssh:** | ||
- | |||
- | su -s /bin/bash autossh | ||
- | vim .ssh/config | ||
- | |||
- | < | ||
- | Host autportven-prod | ||
- | HostName 10.0.20.30 | ||
- | Port 22 | ||
- | User extraway | ||
- | Localforward 8080 localhost: | ||
- | Localforward 5432 localhost: | ||
- | Localforward 19080 10.0.20.31: | ||
- | Localforward 13306 10.0.20.31: | ||
- | </ | ||
- | |||
- | **controllo che il collegamento funzioni e mappi le porte regolarmente: | ||
- | < | ||
- | su -s /bin/bash autossh | ||
- | ssh -g extraway@autportven-prod | ||
- | </ | ||
- | < | ||
- | root@VPN-APV: | ||
- | tcp 0 0 0.0.0.0: | ||
- | tcp 0 0 0.0.0.0: | ||
- | tcp 0 0 0.0.0.0: | ||
- | tcp 0 0 0.0.0.0: | ||
- | </ | ||
- | |||
- | **creo il file di avvio di autossh in systemd:** | ||
- | |||
- | root@VPN-APV:/ | ||
- | |||
- | < | ||
- | [Unit] | ||
- | Description=AutoSSH service | ||
- | Wants=sys-devices-virtual-net-tun0.device | ||
- | After=sys-devices-virtual-net-tun0.device | ||
- | |||
- | [Service] | ||
- | ExecStart=/ | ||
- | |||
- | [Install] | ||
- | WantedBy=multi-user.target | ||
- | </ | ||
- | |||
- | Questo il significato delle opzioni scelte per lo start di autossh: | ||
- | |||
- | **-M port[echo: | ||
- | specifies the base monitoring port to use. Without the echo port, this port and the port immediately above it ( port + 1) should be something nothing else is using. autossh will send test data on the base monitoring port, and receive it back on the port above. For example, if you specify "-M 20000", | ||
- | Setting the monitor port to 0 turns the monitoring function off, and autossh will only restart ssh upon ssh's exit. | ||
- | **In pratica è più consono disabilitare la funzione e usare altri strumenti come ServerAliveInterval e ServerAliveCountMax per controllare se il tunnel è up.** | ||
- | |||
- | |||
- | testo lo script prima di abilitarlo: | ||
- | < | ||
- | root@VPN-APV:/ | ||
- | root@VPN-APV:/ | ||
- | ● 3dautossh.service - AutoSSH service | ||
- | | ||
- | | ||
- | Main PID: 778 (autossh) | ||
- | | ||
- | | ||
- | | ||
- | |||
- | mar 31 15:25:50 VPN-APV autossh[778]: | ||
- | mar 31 15:25:50 VPN-APV autossh[778]: | ||
- | </ | ||
- | **controllo le porte: ** | ||
- | < | ||
- | | ||
- | tcp 0 0 0.0.0.0: | ||
- | tcp 0 0 0.0.0.0: | ||
- | tcp 0 0 0.0.0.0: | ||
- | tcp 0 0 0.0.0.0: | ||
- | </ | ||
- | **abilito il servizio in autostart: | ||
- | < | ||
- | systemctl enable 3dautossh | ||
- | </ | ||
/data/attic/documentazione_3di_riservata/manuali_sysadmin/openvpnautossh.1459498695.txt.gz · Ultima modifica: 2017/09/08 10:59 (modifica esterna)