#!/bin/bash
createTunnel() {
/usr/bin/ssh -f -N -R 2222:localhost:22 ubuntu@HOST
/usr/bin/ssh -f -N -R 8081:localhost:8081 ubuntu@HOST
if [[ $? -eq 0 ]]; then
echo Tunnel created successfully
else
echo An error occurred creating a tunnel. RC was $?
fi
}
/bin/sleep 30
kill `pidof ssh`
echo Creating new tunnel connection
createTunnel
chmod 400 tunnel.ssh
crontab -e
*/15 * * * * /home/pi/tunnel.sh > tunnel.log 2>&1
@reboot /home/pi/tunnel.sh > tunnel.log 2>&1
sudo vi /etc/ssh/sshd_config
GatewayPorts yes
AllowTcpForwarding yes
systemctl reload ssh.service
0 komentarze:
Prześlij komentarz