1

I currently set up sshfs automount on ubuntu per this thread. It's nice because of the network up and down scripts. The benefit comes at a cost: it requires passwordless ssh via an ssh key. I was wondering if anyone had any advice on how to incorporate ssh-agent with this process so that I can use a passworded key for more security. With ssh-agent, I would only have to enter my password once in each session, even for mounting multiple ssh servers as ssh-agent would give the key.

Any help is much appreciated.

Vinh Nguyen
  • 143
  • 5

1 Answers1

1

It's pretty straightforward -- you just start the agent somewhere out of the way, feed it the key(s) of interest, then set the SSH_AUTH_SOCK environment variable in the environment of the sshfs process to point to the agent.

womble
  • 96,255
  • 29
  • 175
  • 230
  • When using a passworded key, I narrowed the issue to "sudo -u my.name sh -c "mount /mnt/my.server". It gives me a "read: Connection reset by peer" error. If I just do "mount /mnt/my.server", ssh-agent would ask me for my password once and store the key in keyring. However, it doesn't work when the script is ran as root, even with the "sudo -u my.name". If I do "sudo -i my.user", and try "mount /mnt/my.server", it also gives me the connection error. "SSH_AUTH_SOCK=/tmp/keyring-kHgERD/ssh mount /mnt/my.server" also does not work when ran as root. Thoughts? – Vinh Nguyen Mar 08 '12 at 17:32
  • Regarding your SSH_AUTH_SOCK, could you be more specific about the solution? That is, provide details on how to implement it? Thanks. PS note that ssh-agent is started automatically in an ubuntu session: /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=2d-gnome – Vinh Nguyen Mar 08 '12 at 17:49
  • 1
    Could you please elaborate a bit on your answer. – Macario Sep 18 '13 at 07:04