From 0079575de85570e2c3e7f953f2b2ac8daa03befb Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Tue, 2 Oct 2018 11:44:14 +0200 Subject: [PATCH] if remote user is root, mount / instead of /home/max --- mnt-sftp.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mnt-sftp.sh b/mnt-sftp.sh index c2514c8..1dd6b64 100755 --- a/mnt-sftp.sh +++ b/mnt-sftp.sh @@ -128,9 +128,15 @@ function mount { fi # Command to mount actually - if [ "$MAN" = "0" ]; then - sshfs -C "$SSH": "$MOUNTDIR"/ -o follow_symlinks & - else + if [ "$MAN" = "0" ]; then # used for hosts in ssh config + # if user of SSH Host is root, use the root directory as SSHPATH instead of $HOME + if [[ $(ssh -G "$SSH" | awk '/^user / { print $2 }') == "root" ]]; then + SSHPATH="/" + else + SSHPATH= + fi + sshfs -C "$SSH":"$SSHPATH" "$MOUNTDIR"/ -o follow_symlinks & + else # used for manually entered or predefined hosts in app's config echo "$SSHPASS" | sshfs -C -o password_stdin -p "$SSHPORT" "$SSHUSER"@"$SSHHOST":"$SSHPATH" "$MOUNTDIR"/ -o follow_symlinks & fi