SSHFS 连接适用于命令,但不适用于 fstab

SSHFS 连接适用于命令,但不适用于 fstab

当我使用命令行连接时,sshfs 可以工作:

jack@lap:~$ sshfs [email protected]:/home/jack/LanDrive ~/LanDrive

但是当我尝试使用以下命令通过 fstab 挂载它时却不行:

sshfs [email protected]:/home/jack/Tabernash/040/home/jack/Tabernash fuse _netdev,delay_connect,allow_other,default_permissions,noauto,IdentityFile=~/.ssh/id_rsa 0 0

或者

[email protected]:/home/jack/Tabernash/040/home/jack/Tabernash fuse default_permissions,noauto,IdentityFile=~/.ssh/id_rsa 0 0

然后

$ sudo findmnt --verify --verbose

返回此:

fuse
   [E] unreachable on boot required target: No such file or directory
   [ ] FS options: 0
   [W] unreachable source: [email protected]:/home/jack/Tabernash/040/home/jack/Tabernash: No such file or directory
   [W] default_permissions,noauto,IdentityFile=~/.ssh/id_rsa seems unsupported by the current kernel
   [W] cannot detect on-disk filesystem type

我尝试过 fstab 中的很多其他变体,但都没有效果。

客户端是运行 Ubuntu 20.04 的桌面,服务器是运行 Ubuntu Server 20.10 的 Raspberry Pi 4。

有什么建议么?

答案1

您看过 s​​ystemd 挂载吗?

# /etc/systemd/system/media.mount (Naming is important)
[Unit]
Description=Mount remote /media with sshfs
Before=cron.service

[Install]
WantedBy=multi-user.target

[Mount]
[email protected]:/media/
Where=/media
Type=fuse.sshfs
Options=_netdev,allow_other,IdentityFile=/root/.ssh/[email protected],reconnect,ServerAliveInterval=30,ServerAliveCountMax=5,x-systemd.automount,uid=1000,gid=1000
TimeoutSec=60

[Install]
WantedBy=multi-user.target

相关内容