scripts/rsshfs: add script for reverse sshfs

This commit is contained in:
Michele Guerini Rocco 2023-06-07 11:07:18 +02:00
parent 6572a5968a
commit c41f7f1eff
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

17
scripts/rsshfs Executable file
View File

@ -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