SSHFS 在命令行上工作,但在 fstab 中不工作

SSHFS works on command line but not within fstab

我正在尝试使用 SSHFS 连接两台服务器。

作为 root,当启动命令 sshfs myuser@ip_adress:/some/dir /other/dir -o idmap=user,identityfile=/home/myuser/.ssh/id_rsa 时,一切正常。

但是,当我在 /etc/fstab 和 运行 mount -a 中设置此 SSHFS 配置时,它挂起。 /etc/fstab 中的行是:

myuser@ip_adress:/some/dir /other/dir  fuse.sshfs defaults,_netdev,IdentityFile=/home/myuser/.ssh/id_rsa 0 0

我尝试了很多选项,但到目前为止,没有任何效果。

通过在 /etc/fstab 选项中添加 ssh_command=ssh0-vv,sshfs_debug,debug 和 运行 mount -av,我得到以下输出:

executing <ssh> <-vvv> <-x> <-a> <-oClearAllForwardings=yes> <-oidentityfile=/home/myuser/.ssh/id_rsa> <-2> <myuser@ip_adress> <-s> <sftp>
OpenSSH_8.4p1 Debian-5, OpenSSL 1.1.1k  25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname ip_address is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/root/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/root/.ssh/known_hosts2'
debug2: ssh_connect_direct
debug1: Connecting to ip_address [ip_address] port 22.
debug1: Connection established.

我不明白为什么此时 SSH 连接挂起。

你知道问题出在哪里吗?

谢谢

所以我发现了问题:我试图挂载 .ssh 文件夹(其中包含连接到远程服务器的密钥)。

我不知道为什么它在命令行上工作而不是通过 fstab(可能与 SSH 代理有关)但安装用于连接到 SSHFS 的文件夹导致了这个问题。我将 SSH 密钥移动到另一个目录,然后它就很好用了。