Mounting multiple directories with sshfs using a script

Check this out. I have this script on my laptop for mounting project directories which are located on my desktop computer. By running mount.sh “my password” , I’m able to mount multiple directories on my laptop LIKE a BOSS.

WARNING!! I no longer advice using this technique.
1. I do not advise the use of plain passwords for ssh connections.
2. This method will expose your password in your .bash_history file, and in active process lists (top, ps).

Use at your own risk.

I strongly suggest the use of SSH KEYS for use with sshfs, rsync, ssh, and any other type of ssh operations!

#!/bin/bash
# mount.sh

echo "$1" | sshfs "amado@killer:/media/G" /media/G -o password_stdin
echo "$1" | sshfs "amado@killer:/home/amado" /media/home -o password_stdin
echo "$1" | sshfs "amado@killer:/media/V" /media/V -o password_stdin

I’ve also recently discovered ssh with X11 forwarding. This is the coolest thing ever. It allows me to run actual programs and windows ON MY LAPTOP as if they were running locally on my DESKTOP. I can even drag & drop files between local and remote filesystems seamlessly. This means I can work on my laptop as if it were my desktop pc. 133t!


  • About

    If anyone comes across this … this is a super bad idea! It will store your password in ~/.bash_history in plain text! Anyone can read this file and find out your password. You shoud _at least_ use read command inside the script or better, use different approach entirely.

  • amado

    Hello. You’re absolutely right! I have abandoned this technique and now I use ssh-keys for everything ssh-related. Thanks for your comment! I will update the post with a warning.