TUNNEL SSH

ssh-keygen -t rsa -b 4096      // création clef ssh ( si pas déjà fait)

ssh  user@dev.monserveur.com  <-password // première connexion serveur relais manuelle

ssh-copy-id root@ monserveur.com  // copie clef

dans sshd_config ajouter :  GatewayPorts yes
/etc/init.d/ssh restart  //(debian)

ssh -R 4444:localhost:80 user@dev.monserveur.com
en se connectant sur dev.monserveur.com:4444 c'est localhost:80 qui répond.

autossh   -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3"  -R 4444:localhost:80 user@dev.monserveur.com 
même chose mais en tache de fond avec reconnexion automatique

Lancement au boot ajouter un fichier /etc/systemd/system/autossh-tunnel.service
[Unit]
Description=AutoSSH tunnel service local 80 port 4444 dev.monserveur.mobi
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 4444:localhost:80 root@dev.monserveur.mobi
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

puis:
sudo systemctl start autossh-tunnel.service
sudo systemctl stop autossh-tunnel.service
sudo systemctl enable autossh-tunnel.service  pour démarrage auto

https://wiki.archlinux.fr/Autossh



     

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

− two = six