A
A
Alexey Yarkov2019-03-28 14:16:24
linux
Alexey Yarkov, 2019-03-28 14:16:24

How to trace a broken connection using bash?

To get started, I sequentially execute 2 commands in the terminal:
Connect to the VPN
$ ssh -D 9999 -N vpn &
And run the script where ports are forwarded to the VPN
$ ./proxy.sh
And now the process ./proxy.shhangs, and I work in the next tab of the terminal.
But periodically there is a disconnection and the process ./proxy.shstops.
Can I somehow track this moment and display, for example, Notification or somehow notify?
Script content ./proxy.sh:

#!/bin/bash

ssh \
  -L 9080:loc0.domain.com:80 \
  -L 9081:loc1.domain.com:80 \
  -L 9082:loc2.domain.com:80 \
  -N vpn

Googled the option -o "ServerAliveInterval 60". Apparently this is what you need?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2019-03-28
@yarkov

And it’s trite to add output to the screen in proxy.sh

#!/bin/bash

ssh \
  -L 9080:loc0.domain.com:80 \
  -L 9081:loc1.domain.com:80 \
  -L 9082:loc2.domain.com:80 \
  -N vpn
echo "************ Proxy has been terminated ********"

And run it in the same tab where you work?
You can also add a 07 character to make it buzz.
You can put the launch of the proxy in an eternal while until you interrupt it yourself.
See what is more convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question