Skip to content

Instantly share code, notes, and snippets.

@caputomarcos
Forked from volkstrader/start_rssh_tunnel.sh
Created March 17, 2022 20:00
Show Gist options
  • Save caputomarcos/b37f69e77e2945ec533cb981f5ce90b2 to your computer and use it in GitHub Desktop.
Save caputomarcos/b37f69e77e2945ec533cb981f5ce90b2 to your computer and use it in GitHub Desktop.
Start reverse ssh tunnel for cron job
#!/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)
@caputomarcos
Copy link
Author

crontab -e
*/5 * * * * /usr/local/bin/jobs/start_rssh_tunnel.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment