-
-
Save caputomarcos/b37f69e77e2945ec533cb981f5ce90b2 to your computer and use it in GitHub Desktop.
Start reverse ssh tunnel for cron job
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_REDIR_PORT=12345 | |
SSH_D="cloud_sshd" | |
COMMAND="ssh -R $SSH_REDIR_PORT:localhost:22 $SSH_D -N -f" | |
pgrep -f "ssh -R $SSH_REDIR_PORT:localhost:22" > /dev/null 2>&1 || (eval $COMMAND && echo $COMMAND) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
crontab -e
*/5 * * * * /usr/local/bin/jobs/start_rssh_tunnel.sh