From 7b5d702e202e3e3b6d00670ecd670505071a4f54 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 26 Apr 2020 08:20:30 -0500 Subject: Add key and rest fields and improve ssh calls --- README.md | 10 ++++++++-- mrgrctrnl | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7d92514..b1f724a 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,16 @@ with whitespace-separeted fields. A `#` begins a comment that goes to the end of the line. ``` -# machine user local remote -example.com ted localhost:6989 localhost:6667 +# machine user local remote key rest +example.com ted localhost:6989 localhost:6667 /path/to/key.pub [..] ``` +**machine**, **user**, **local**, and **remote** are required. +**key** and **rest** are optional. + +**rest** is more command-line options, if there's anything else you'd like to +include in the command. + ## Requirements - POSIX environment diff --git a/mrgrctrnl b/mrgrctrnl index 1229993..ca17f55 100755 --- a/mrgrctrnl +++ b/mrgrctrnl @@ -70,19 +70,24 @@ then demolish_tunnels fi awk '{sub(/#.*$/,"");print}' "$config" | -while read -r machine user local remote +while read -r machine user local remote key rest do if [ -z "$machine" ] || [ -z "$user" ] || [ -z "$local" ] || [ -z "$remote" ] then continue fi - echo ssh -N "$user@$machine" -L "$local:$remote" + set -- -N "$user@$machine" -L "$local:$remote" + [ -n "$key" ] && set -- "$@" -i "$key" + #shellcheck disable=2086 + [ -n "$rest" ] && set -- "$@" $rest + + echo ssh "$@" "$dry_run" || { while : do - ssh -N "$user@$machine" -L "$local:$remote" + ssh "$@" echo "$!" >> "$pidf" sleep 5 done & -- cgit 1.4.1-21-gabe81