필요에 따라 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!

답변2

설명은 다음과 같습니다.

참고: /etc/fstab을 편집한 후 필요한 서비스를 (다시) 시작합니다. systemctl daemon-reload && systemctl restart는 <target>systemctl list-unit-files --type automount를 실행하여 찾을 수 있습니다.

질문이 있습니다 :-(.

systemd로 구현된 마운트 옵션(예: )은 이 명령으로 구현 x-systemd.*되지 않습니다 .mount

그러나 권한이 없는 사용자(root/sudo 없음)이고 fstab 항목(허용 또는 설치 옵션으로 표시됨)을 설치하려는 경우 mount이 명령을 사용해야 합니다.userusers

답변3

나는 이것이 매우 오래된 게시물이라는 것을 알고 있지만 방금 sshfs를 설정하고 비슷한 문제에 직면했습니다. 나를 위한 해결책은 비밀번호 없이 rsa 키를 생성하는 것이었습니다. 왜냐하면 systemd automount를 사용하여 자동으로 마운트할 때 ID 파일 비밀번호를 묻는 메시지가 표시되지 않기 때문입니다.

관련 정보