lon*_*nix 2 ssh sftp ubuntu fstab sshfs
我按照sshfs“按需”安装的说明进行操作,但它不起作用。
我将此添加到/etc/fstab:
username@hostname:/ /mnt/remotes/hostname fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0
Run Code Online (Sandbox Code Playgroud)
然后我跑了,sudo mount -a什么也没做。我也尝试过systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount。
所以我按照故障排除提示,并使用了这个:
username@hostname:/ /mnt/remotes/hostname fuse.sshfs ssh_command=ssh\040-vv,sshfs_debug,debug,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0
Run Code Online (Sandbox Code Playgroud)
然后就跑了sudo mount -av。在一个单独的终端中,我可以访问该安装点。
所以 1) ssh 和 sftp 正在工作,2) sshfs 正在工作,3) 权限很好。
所以只有点播部分不起作用 - 我做错了什么?
这些说明令人困惑,尤其是对于不了解 systemd 的人来说。
正确的程序:
添加/etc/fstab:username@hostname:/ /mnt/remotes/hostname fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0
跑步sudo systemctl daemon-reload。这将创建一个 systemd“单元文件”。
通过运行找出哪个单元文件systemctl list-unit-files --type automount。对我来说是的mnt-remotes-hostname.automount。
启用它:sudo systemctl restart mnt-remotes-hostname.automount.
cd /mnt/remotes/hostname或者ls /mnt/remotes/hostname它会自动创建 sftp 连接!
这可行,但我还不确定:
allow_other存在安全风险,我需要调查一下 如果有人能阐明这一点,请这样做。
更新
根据@sourcejedis的回答,停止安装必须按以下顺序完成:systemctl stop whatever.mount && systemctl stop whatever.automount并且不应使用umount mounpoint!
| 归档时间: |
|
| 查看次数: |
4115 次 |
| 最近记录: |