misc/scripts/rsshfs

18 lines
372 B
Bash
Executable File

#!/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