![]() ![]() Just by chance, I tried to call bash instead of tail -f ( bash seems to me "neverending" command, too), but it doesn't work. #Persistent ssh tunnel plusIt works now! But, this solution seems a bit ugly, plus I don't really understand actual reasons of that behavior. some "neverending" command, so I just created empty file /tmp/dummy_file and now my ssh command looks like this: ssh -o ServerAliveInterval=240 -R 2225:localhost:22 -n tail -f /tmp/dummy_file Now the SSH client at local will connect to SSH server running at remote (usually running at ssh port 22) binding port 9001 of local to listen for local. #Persistent ssh tunnel how toIf you are on Ubuntu, for example, you can do a web search for autossh upstart to find some useful examples on how to configure Ubuntu so that the tunnel is kept up in a persistent fashion. Unit DescriptionEstablish persistent SSH tunnel rvice Wantsnetwork-online.target Afternetwork-online. Rather than connecting directly to the target network, the client instead connects to. Then, I just looked around for similar scripts and I found that it works if I call tail -f something, i.e. In addition it monitors the connection using extra tunnels, which makes it highly useful for scenarios like the one you are asking about. SSH Reverse Tunnels use traffic-forwarding to bypass network restrictions. (so, the script above reconnects all the time)įrom man ssh, I found that for background connections I should call it with -n key, but it didn't help. SSH Persistent Tunnel (SPT) tries to maintain ssh tunnels over the frequent change of network and disconnects typical for a mobile device. Start the ssh tunnel using autossh: autossh -f -D 5555 -N -M 0 Testing. The most common tunnels are remote and local. But I found out that works if only I execute it "by hand" from shell, but if it is called by cron, ssh connects and immediately finishes. Besides sending ssh data, the ssh protocol can tunnel other traffic between two hosts. Ssh -o ServerAliveInterval=240 -R 2225:localhost:22 "restarting in 5 seconds."Īnd added it to the /etc/crontab. ![]() Related question: initiate ssh connection from server to clientĪnswer from there helped me a lot, this command does what I need: ssh -R 2225:localhost:22 I wrote the script to reconnect all the time: #!/bin/bash ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |