For this example, let's assume the following parameters:
- username on remote host: user
- password on remote host: password
- remote host: host.com
- directory: /directory
- mount point: /media/ssh
- A file containing just your password, followed by a newline. In the example, I will assume this file is located at /home/user/.pwd. If your password is "password", it should look like this:
password
A bash script that indicates how to use sshpass. In the example, I will assume that this file is located at /home/user/ssh.sh. Note that the location of your .pwd file must be included after the -f option. This file must be made executable.
#!/bin/bash
sshpass -f /home/user/.pwd ssh $*
sudo mount -t fuse sshfs#user@host.com:/directory /media/ssh -o ssh_command=/home/user/ssh.sh
However, the title of this post is automounting, so let's do that. To automount this ssh server, you can add a line like this to your /etc/fstab:
sshfs#user@host.com:/directory /media/ssh fuse ssh_command=/home/user/ssh.sh 0 0
That's it. Pretty cool. Hope you find it as useful as I do.