aboutsummaryrefslogtreecommitdiff
path: root/shellrc.d/ssh
blob: e2882c8ca4642067310ca3e4563541ec461b4273 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# vim: ft=sh:

# SSHFS in client mode. In other words it is reverse sshfs mount.
sshcfs() {
	local target="$1"
	local local_dir="$2"
	local remote_dir="$3"
	shift 3
	[[ "$local_dir" = /* ]] || local_dir="$PWD/$local_dir"

	local sftp_server="/usr/lib64/misc/sftp-server"
	if [ -e /run/current-system/sw/bin/ssh ]; then
		sftp_server="$(readlink -f /run/current-system/sw/bin/ssh)"
		sftp_server="${sftp_server%/bin/ssh}/libexec/sftp-server"
	fi

	ssh "$@" "$target" mkdir -p "$remote_dir"
	dpipe \
		"$sftp_server" \
		= \
		ssh "$@" "$target" sshfs -o idmap=user -o passive -o allow_other \
			":$local_dir" "$remote_dir"
}