How to specify key in SSHFS?

Here's what works for me:

sshfs [email protected]:/remote/path /local/path/ -o IdentityFile=/path/to/key

You can figure this out via man sshfs:

-o SSHOPT=VAL ssh options (see man ssh_config)

man ssh_config

IdentityFile

Specifies a file from which the user's DSA, ECDSA or DSA authen‐ tication identity is read.


What you need to do is specify which private key to use in the ~/.ssh/config file. for example:

Host server1.nixcraft.com
    IdentityFile ~/backups/.ssh/id_dsa
Host server2.nixcraft.com
    IdentityFile /backup/home/userName/.ssh/id_rsa

sshfs -o ssh_command='ssh -i path/to/keyfile/id_rsa.2' username@ipaddress:/path /local/path