folks. Recently I came over autofs and now trying to make my everyday life easier. I have a remote server that I use as I file share with a help of sshfs for years. So, I found some tutorials how to automate sshfs with a help of autofs. Here are my configs:
auto.master:
/home/user/autofs/ /etc/autofs/auto.sshfs uid=1000,gid=1000,--timeout=300,--ghost
auto.sshfs:
cux -fstype=fuse,port=222,rw,nodev,noatime,allow_other,IdentityFile=/home/user/.ssh/id_rsa :sshfs\#user@server.com\:/path/to/files
The remote server accepts only ssh keys, so the user who is trying to access the mount point has an ssh-agent running with keys imported.
But when I'm trying to access the mount point I get:
Dec 31 18:56:37 ice automount[25565]: mount(generic): calling mount -t fuse -o uid=1000,gid=1000,port=222,rw,nodev,noatime,allow_other,IdentityFile=/home/user/.ssh/id_rsa sshfs#user@server.com:/path/to/files /home/user/autofs/cux
Dec 31 18:56:37 ice automount[25565]: spawn_mount: mtab link detected, passing -n to mount
Dec 31 18:56:37 ice automount[25565]: >> read: Connection reset by peer
Dec 31 18:56:37 ice automount[25565]: mount(generic): failed to mount sshfs#user@server.com:/path/to/files (type fuse) on /home/user/autofs/cux
Dec 31 18:56:37 ice automount[25565]: dev_ioctl_send_fail: token = 67
Dec 31 18:56:37 ice automount[25565]: failed to mount /home/user/autofs/cux
But if I mount with sshfs (from my user):
sshfs -p 222 server.com:/path/to/files /home/user/remote/cux -o reconnect
It succeeds. Even if I use exactly the same command as autofs run from root as autofs does:
mount -t fuse -o uid=1000,gid=1000,port=222,rw,nodev,noatime,allow_other,IdentityFile=/home/user/.ssh/id_rsa sshfs#user@server.com:/path/to/files /home/user/autofs/cux
It succeeds as well. But it looks like the problem is the ssh keys. If I run the mount command from root having no user keys imported (su -), the password will be prompted. Is there is a way to get around this problem and make autofs use ssh keys of the user who is accessing the mountpoint?