I'm establishing a reverse tunnel with $ ssh -fN -R 19999:localhost:22 -i aws-mycert.pem [email protected] and need to make sure it stays up & running even past a server reset. How can I check for the connection in a cron script that then re-establishes the connection autiomatically when required?
check and auto re establish reverse ssh tunnel
1.8k Views Asked by stdcerr At
1
There are 1 best solutions below
Related Questions in AMAZON-S3
- Mocking AmazonS3 listObjects function in scala
- S3 integration testing
- Error **net::ERR_CONNECTION_RESET** error while uploading files to AWS S3 using multipart upload and Pre-Signed URL
- Golang lambda upload image into s3 static website
- How to take first x seconds of Audio from a wav file read from AWS S3 as binary stream using Python?
- AWS Lambda Trigger For Same S3 File Name In Quick Succession
- Is there a way to upload a file in digital ocean object storage using php curl
- How to setup AWS credentials for next.js apps?
- S3 pre-signed url not working on whatsapp cloud Api
- How to set custom Origin Name in AWS CDK for CloudFront
- Property 'location' does not exist on type 'File'
- Resource handler returned message: "Unable to validate the following destination configurations
- Webmin CentOS7 AWS backup errors - perl(S3::AWSAuthConnection) can't be installed
- How to access variable to pass through url_for() as src in Flask App
- I cant figure out how to pull scripts from s3 to my aws workspace
Related Questions in CRON
- is there a solution to run cron job command in cpanel only from my cPanel host?
- crontab run every minute after 9pm
- Python3.11 can't open file [Errno 2] No such file or directory
- Overwhelming of the Agenda cron jobs on the server
- How to schedule cron job in spring boot to run for every 5 minutes with in specific period
- Building a service which sends emails everyday to the user at a particular time. (NOT RUNNING)
- Extend function execution on product update via a Cron Job or REST_API
- Activity status in Node js
- Azure YAML Pipeline schedule to run on the last Sunday of the month at 4 AM
- Run scheduler on authenticated api
- I would like to Create a schedule in Databricks that runs a job on 1st working day of every month
- Add and Replace Jobs in Crontab
- Moodle Forum notifctions
- python3 working on terminal but not on cron job
- Context Deadline exceeded and WebSocket Url timeout issue
Related Questions in SSH-TUNNEL
- Nmap scan returns all ports open when ran with proxychains through a Linux <-> Windows SSH tunnel
- How to connect MySql Database using SSH to Looker Studio?
- Accessing with python and sshtunnel not possible on Mac?
- sshtunnel connect failed towards mysql container on NAS drive
- SSl-TLS encryption by a jdbc connector. Can I switch it off?
- utm virtual machine ssh connect drop after few minutes
- Cannot connect (TimeOut) to MySQL using nodejs mysql2 via ssh tunnel
- Setup a ssh local port forwarding with Python's sshtunnel
- Remote ssh vscode: bind: Address already in use channel_setup_fwd_listener: cannot listen to port
- How can Metaflow FlowSpec instance be wrapped in a context manager without the context manager getting called twice?
- API (accessible via jumpbox server) testing using JMeter
- How to use Python SSHTunnle to forward multiple ports to two DB
- How does SSH frame/packet/segment look like (structure)
- SSHTunnelForwarder sometimes works as intended, sometimes errors out, sometimes hangs indefinitely
- ssh picking wrong private key even after config file change
Related Questions in DYNDNS
- Cant Use a Subdomain in NGINX Proxy Manager
- Dynamic DNS Security
- dynamic dns not being picked up
- Python socket over DDNS
- Does nsupdate reformat reverse zone files
- 2 Homeservers 2 Domains possibel?
- How to redirect a url to a dynamic ip address but keep domain name in address bar? Dynamic DNS
- Why does my apache2 Website domain get resolved to my external ip address of my network?
- Using "ddclient" with a custom URL (php-Script on my Server)
- Dynamic DNS for IPv6 results in IP address could not be found
- How to port forward for DynDNS without touching the NAT router
- Dyndns2 protocol specification?
- Host server on Raspberry
- What kind of redirection Type is dyndns using?
- Port Forwarding issue on Netgear D7000v2
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
A simple way of doing this is using Netcat. The command
nc -z localhost 19999will check if there is something in the local port 19999 listening, so you could use:nc -z localhost 19999 || ssh -fN -R 19999:localhost:22 -i aws-mycert.pem [email protected]to recreate the tunnel if needed.However, this only checks that the tunnel is up, but it might be stale. The best solution is to use autossh. Just install it in your machine and use:
autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -fN -R 19999:localhost:22 -i aws-mycert.pem [email protected]Then you just need to run this command when the server starts, which depends on your distribution.
You can find more details on using autossh at https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/.