![]() The content of the wrapper autossh is as follows, in Ubuntu 20.04: ➜ ~ uname -a The shell script is just to randomize a port (if not specified) (for 42 times) and pass it to the real autossh located at /usr/lib/autossh/autossh. ![]() Several package wraps the real autossh command by a shell script, located at /usr/bin/autossh. In fact, the real autossh binary file always requires a parameter called monitor port for which that port is used to send and the port immediate above it ( port + 1) is used to receive data. In the next step, add -M 2230 to the autossh command. Default is 30 seconds use of -fĪUTOSSH_LOGFILE - file to log to (default is to use the syslogĪUTOSSH_LOGLEVEL - level of log verbosityĪUTOSSH_MAXLIFETIME - set the maximum time to live (seconds)ĪUTOSSH_MAXSTART - max times to restart (default is no limit)ĪUTOSSH_MESSAGE - message to append to echo string (max 64 bytes)ĪUTOSSH_PATH - path to ssh if not defaultĪUTOSSH_POLL - how often to check the connection (seconds)ĪUTOSSH_FIRST_POLL - time before first connection check (seconds)ĪUTOSSH_PORT - port to use for monitor connectionĪUTOSSH_DEBUG - turn logging to maximum verbosity and log toĬhoose a random port for which that port and the port immediately above it ( port + 1) is free, for e.g.: 2230, then 22 ports must be free. f run in background (autossh handles this, and does notĪUTOSSH_GATETIME - how long must an ssh session be establishedīefore we decide it really was established 0 turns monitoring loop off.Īlternatively, a port for an echo service on the remote In that case, you have to do continue this section. ) or the command succeeds, you can skip this step. Otherwise, if other errors appear (e.g., unauthorized. TLDR try running autossh if the usage of autossh appears, you need to do this step. The most reliable method will be used in this post. This post lists all 3 ways to create a startup script in general. In this post, I advance the topic by introducing how to create a systemd service and start the service automatically in background after the OS boots. If check failed, then try to establish a new reverse session to your server.In the previous post, I have introduced how to create a reverse tunnel to access your local machine from a remote machine, by pass the firewall, or, access a network in the behavior of another machine. PrivateKeyToAccessCentralServer='/path/to/the/private/ssh/ServerKey.pem' # (use public key authentication, so you don't need You don't need to run commands from cron via sudo.Ĭreate some script like this one below and put it in the home directory of the user that will establish reverse SSH connection to your server: #!/bin/sh ![]() I created the certificates without a password, and I sent it from remote Raspberry to server in order to make no login access. If, on remote server, I run this code: sudo /usr/bin/ssh -gNnT -R 2222:localhost:22 all works correctly, but if I run it from the crontab script, it does not work. This system functions very well, but I can't use it to establish the reverse tunnel. Sudo wget -c -output-document=ipdiscover.php "comando=$(cat ipdiscover.php) Here is the code of the crontab file: #! /bin/bash I've implemented on my website a system to send to remote Raspberries single commands.Įvery remote Raspberry checks every minute (crontab) the presence of commands available, and if is there is one, then it downloads the command, creates an executable file and runs it. I've many remote Raspberry using NAT inside their LANs, and one Raspberry that I use as server, reachable from the Internet. For many days, I've wondered how to automate the establishment of a reverse tunnel.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |