Last active
May 19, 2021 06:49
-
-
Save isheev/755f5c0e2309e3eda08648c30b0d6114 to your computer and use it in GitHub Desktop.
Start ssh tunnel for CRON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SSH_USER="user" | |
SSH_SERVER_IP="server" | |
REDIRECT_PORT_FROM=234567 | |
REDIRECT_PORT_TO=22 | |
pgrep -f $REDIRECT_PORT_FROM:localhost || ssh -R $REDIRECT_PORT_FROM:localhost:REDIRECT_PORT_TO $SSH_USER@$SSH_SERVER_IP -N -f | |
#Add to CRON for running every minute | |
#* * * * * sh $HOME/start_ssh_tunnel.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment