31

I am trying to mount a folder on my amazon ec2 instance to my desktop folder using sshfs.

The problem is that I am not able to figure out how to give the option for private key (awskey.pem).

Normally I ssh using

ssh ec2-user@{amz-ip-address} -i {path to amzkey.pem}

But sshfs has no such options. However I saw a -F option and tried

sshfs ec2-user@{amz-ip-address}:{amz-folder}  {my mount dir} -F {path to amzkey.pem}

This gave me an error

"read: Connection reset by peer"

Please let me know if anyone has tried this before.

HRM
  • 2,097
  • 6
  • 23
  • 37
Sanath Ballal
  • 1,648
  • 4
  • 22
  • 31

2 Answers2

45

From the documentation:

If you are using non-default key names and are passing it as -i .ssh/my_key, this won't work. You have to use -o IdentityFile=/home/user/.ssh/my_key, with the full path to the key.

Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
  • 1
    And I just confirmed that this works. +1. This answer should be accepted. – slayedbylucifer Mar 06 '14 at 11:35
  • 3
    I also found that you must use full, explicit path of local folder. For instance, `~/remoteDir` did not work for me while `/home/user/remoteDir` does. – brock Jun 27 '16 at 15:15
  • In my case the issue was with a relative path to the key. Worked ok with an absoulte path. – egst Nov 30 '22 at 16:32
30

Here is the command for anyone trying this in future

sudo sshfs {username}@{ipaddress}:{remote folder path}  {local folder path} -o IdentityFile={full path to the private key file} -o allow_other
ajay
  • 9,402
  • 8
  • 44
  • 71
Sanath Ballal
  • 1,648
  • 4
  • 22
  • 31
  • 4
    What `-o allow_other` does here? – Bunyk Oct 09 '17 at 12:50
  • 4
    "-o allow_other" allows for non sudo access to the mounted directory. this is useful when sshfs itself needed sudo, so without "-o allow_other" you'd have to work with su on the mounted directory for every command – mork Jan 11 '19 at 20:55
  • 2
    I can confirm this works great and with Sublime. Thanks! – Harlin Feb 13 '21 at 15:54