dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit ec52fd254e900eba75bfd01c9d1560503fdff4f8
parent 4eaee0b9ab534641cf9260ea63b01b3e54bc90b1
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 18 Sep 2020 12:17:23 +0200

Merge branch 'master' of src.adamsgaard.dk:dotfiles

Diffstat:
A.local/bin/ssh-tunnel-adamsgaard | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/.local/bin/ssh-tunnel-adamsgaard b/.local/bin/ssh-tunnel-adamsgaard @@ -0,0 +1,22 @@ +#!/bin/sh +# add some cron entry to keep the tunnel alive across reconnects: +# */2 * * * * ~/.local/bin/ssh-tunnel-adamsgaard >/dev/null 2>&1 +remote="adamsgaard.dk" +identity="~/.ssh/id_rsa_ad" + +die() { + printf '%s: error: %s\n' "$1" >&2 + exit 1 +} + +create_tunnel() { + if ssh -i "$identity" -f -N -R 10022:localhost:22 -L19922:"$remote":22 "$remote" >/dev/null; then + printf 'tunnel to %s created successfully\n' "$remote" + else + die "could not create tunnel to $remote ($?)" + fi +} + +if ! ssh -i "$identity" -p 19922 localhost ls >/dev/null 2>&1; then + create_tunnel +fi