SSHFS启动CentOS 6.3

我编辑了文件/etc/rc.d/rc.local并添加了以下几行代码,以便在启动时通过sshfs挂载远程目录:

 su user -c "/usr/bin/sshfs -o idmap=user -o reconnect -o allow_other -o uid=500 -o gid=500 user@remote:/home/shares/allusers /home/user/mnt" 

问题是没有在启动时挂载目录,但是当我在login之后手动执行这个命令,所有的工作都按预期工作,这个目录就被挂载了。

有什么build议么?

尝试添加

sshfs#user @ remote:/ home / shares / allusers / home / user / mnt“fuse defaults,idmap = user

到/ etc / fstab

用mount -atesting一下,如果没问题,重启

rc.local将以root用户身份执行,因此您需要确保root拥有一个可在远程主机上与指定用户一起使用的SSH密钥,或指定与-o IdentityFile=/home/user/.ssh/my_key一起使用的密钥-o IdentityFile=/home/user/.ssh/my_key *。

*无法testing,因为它看起来像我的版本的sshfs太旧,没有选项。

根据以前的答案build议,不要将mount -a添加到rc.local ,只需将delay_connect添加为fstab选项即可。

(这可能是一个评论,但我的人数太less)