Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 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.

share|improve this answer
    
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 8 '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 8 '12 at 17:49
    
Could you please elaborate a bit on your answer. –  Macario Sep 18 '13 at 7:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.