From 9472181f2880c3558fcc80439cd9b92ef2b3b086 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Sep 2021 11:24:32 +0200 Subject: l sshify: init --- lass/2configs/default.nix | 1 + lass/5pkgs/sshify/default.nix | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 lass/5pkgs/sshify/default.nix (limited to 'lass') diff --git a/lass/2configs/default.nix b/lass/2configs/default.nix index adfeef19d..eb38d0e97 100644 --- a/lass/2configs/default.nix +++ b/lass/2configs/default.nix @@ -117,6 +117,7 @@ with import ; iftop tcpdump mosh + sshify #stuff for dl aria2 diff --git a/lass/5pkgs/sshify/default.nix b/lass/5pkgs/sshify/default.nix new file mode 100644 index 000000000..aba0ab6bb --- /dev/null +++ b/lass/5pkgs/sshify/default.nix @@ -0,0 +1,38 @@ +{ pkgs }: +pkgs.writers.writeBashBin "sshify" '' + set -efu + + TMPDIR=$(mktemp -d) + + SSH_ARGS=() + + while [[ "$#" -gt 0 ]]; do + case $1 in + --) + shift + break + ;; + *) + SSH_ARGS+=($1) + ;; + esac + shift + done + + if [[ "$#" -le 0 ]]; then + echo no command specified + exit 1 + fi + + RANDOM_HIGH_PORT=$(shuf -i 20000-65000 -n 1) + + cat << EOF >$TMPDIR/proxychains.conf + [ProxyList] + socks4 127.0.0.1 $RANDOM_HIGH_PORT + EOF + + ssh -fNM -S "$TMPDIR/socket" -D "$RANDOM_HIGH_PORT" "''${SSH_ARGS[@]}" + trap "ssh -S $TMPDIR/socket -O exit bla 2>/dev/null; rm -rf $TMPDIR >&2" EXIT + + ${pkgs.proxychains-ng}/bin/proxychains4 -q -f "$TMPDIR/proxychains.conf" "$@" +'' -- cgit v1.2.3