From c41f7f1eff2d331b089b16ccd75db2cbc8e50721 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 7 Jun 2023 11:07:18 +0200 Subject: [PATCH] scripts/rsshfs: add script for reverse sshfs --- scripts/rsshfs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 scripts/rsshfs diff --git a/scripts/rsshfs b/scripts/rsshfs new file mode 100755 index 0000000..7b0760d --- /dev/null +++ b/scripts/rsshfs @@ -0,0 +1,17 @@ +#!/bin/sh + +# reversed sshfs - mount a local directory on a host + +ssh="$(dirname "$(readlink "$(command -v ssh)")")/.." +host=$(echo "$2" | sed 's/\(.*\):.*/\1/') +mount=$(echo "$2" | sed 's/.*:\(.*\)/\1/') +path=$1 +shift 2 + +pipe=$(mktemp -u) +mkfifo "$pipe" +exec 3<>"$pipe" +rm "$pipe" + +"$ssh/libexec/sftp-server" <&3 | +ssh "$host" sshfs ":$path" "$mount" -o passive "$@" >&3