必要に応じてSSHFSをインストールする

必要に応じて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

それから逃げて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

そして彼は逃げたsudo mount -av。別の端末からマウントポイントにアクセスできます。

したがって、1) ssh と sftp が稼働中、2) sshfs が稼働中、3) 権限が正常です。

これにより、オンデマンド部分のみが機能しません。私が何を間違っているのでしょうか?

ベストアンサー1

これらのガイドラインは、特にsystemdを知らない人にとっては混乱しています。

正しい手順:

  1. 次に追加/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

  2. ランニングsudo systemctl daemon-reload。これにより、システム化された「単位ファイル」が作成されます。

  3. を実行して、どのユニットファイルが何であるかを調べますsystemctl list-unit-files --type automount。私としてはそうですmnt-remotes-hostname.automount

  4. 活動化: sudo systemctl restart mnt-remotes-hostname.automount

  5. cd /mnt/remotes/hostnameまたは、ls /mnt/remotes/hostname自動的にSFTP接続が作成されます!

これはうまくいきますが、まだわかりません。

  • 誰かがallow_otherセキュリティ上のリスクがあると言っていますが、調査する必要があります。
  • マウントを自動的にマウント解除する時期(アイドル時間数秒など)を指定する方法がわかりません。

誰もがこれについて明らかにできる場合は、そうします。


修正する @sourcejedisの回答によると、インストールの停止は次の順序で実行する必要があり、systemctl stop whatever.mount && systemctl stop whatever.automount使用しないでくださいumount mounpoint

おすすめ記事