sshfs with on-demand mounting

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I followed instructions for sshfs "on demand" mounting, but it doesn't work.



I added this to /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


Then I ran sudo mount -a which did nothing. I also tried systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount.



So I followed the troubleshooting tips, and used this instead:



username@hostname:/ /mnt/remotes/hostname fuse.sshfs ssh_command=ssh40-vv,sshfs_debug,debug,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0


And then ran sudo mount -av. In a separate terminal I could access that mount point.



So 1) ssh and sftp are working, 2) sshfs is working, 3) permissions are fine.



So only the on-demand part isn't working - what am I doing wrong?










share|improve this question























  • By the way, I know about autofs, but I don't want to use it because it only works for root.
    – lonix
    Sep 5 at 16:59










  • it is preferred to use the "edit" link underneath the answer to update it, rather than adding separate comments.
    – sourcejedi
    Sep 5 at 17:53










  • The comment has nothing to do with the question, I'm expecting an answer of the "why don't you rather use tool XYZ", so I tried to avoid it :)
    – lonix
    Sep 5 at 18:29














up vote
0
down vote

favorite












I followed instructions for sshfs "on demand" mounting, but it doesn't work.



I added this to /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


Then I ran sudo mount -a which did nothing. I also tried systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount.



So I followed the troubleshooting tips, and used this instead:



username@hostname:/ /mnt/remotes/hostname fuse.sshfs ssh_command=ssh40-vv,sshfs_debug,debug,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0


And then ran sudo mount -av. In a separate terminal I could access that mount point.



So 1) ssh and sftp are working, 2) sshfs is working, 3) permissions are fine.



So only the on-demand part isn't working - what am I doing wrong?










share|improve this question























  • By the way, I know about autofs, but I don't want to use it because it only works for root.
    – lonix
    Sep 5 at 16:59










  • it is preferred to use the "edit" link underneath the answer to update it, rather than adding separate comments.
    – sourcejedi
    Sep 5 at 17:53










  • The comment has nothing to do with the question, I'm expecting an answer of the "why don't you rather use tool XYZ", so I tried to avoid it :)
    – lonix
    Sep 5 at 18:29












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I followed instructions for sshfs "on demand" mounting, but it doesn't work.



I added this to /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


Then I ran sudo mount -a which did nothing. I also tried systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount.



So I followed the troubleshooting tips, and used this instead:



username@hostname:/ /mnt/remotes/hostname fuse.sshfs ssh_command=ssh40-vv,sshfs_debug,debug,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0


And then ran sudo mount -av. In a separate terminal I could access that mount point.



So 1) ssh and sftp are working, 2) sshfs is working, 3) permissions are fine.



So only the on-demand part isn't working - what am I doing wrong?










share|improve this question















I followed instructions for sshfs "on demand" mounting, but it doesn't work.



I added this to /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


Then I ran sudo mount -a which did nothing. I also tried systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount.



So I followed the troubleshooting tips, and used this instead:



username@hostname:/ /mnt/remotes/hostname fuse.sshfs ssh_command=ssh40-vv,sshfs_debug,debug,_netdev,users,idmap=user,IdentityFile=/home/stanley/.ssh/my_rsa_key,allow_other,reconnect 0 0


And then ran sudo mount -av. In a separate terminal I could access that mount point.



So 1) ssh and sftp are working, 2) sshfs is working, 3) permissions are fine.



So only the on-demand part isn't working - what am I doing wrong?







ubuntu ssh fstab sftp sshfs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 5 at 18:30

























asked Sep 5 at 16:59









lonix

31719




31719











  • By the way, I know about autofs, but I don't want to use it because it only works for root.
    – lonix
    Sep 5 at 16:59










  • it is preferred to use the "edit" link underneath the answer to update it, rather than adding separate comments.
    – sourcejedi
    Sep 5 at 17:53










  • The comment has nothing to do with the question, I'm expecting an answer of the "why don't you rather use tool XYZ", so I tried to avoid it :)
    – lonix
    Sep 5 at 18:29
















  • By the way, I know about autofs, but I don't want to use it because it only works for root.
    – lonix
    Sep 5 at 16:59










  • it is preferred to use the "edit" link underneath the answer to update it, rather than adding separate comments.
    – sourcejedi
    Sep 5 at 17:53










  • The comment has nothing to do with the question, I'm expecting an answer of the "why don't you rather use tool XYZ", so I tried to avoid it :)
    – lonix
    Sep 5 at 18:29















By the way, I know about autofs, but I don't want to use it because it only works for root.
– lonix
Sep 5 at 16:59




By the way, I know about autofs, but I don't want to use it because it only works for root.
– lonix
Sep 5 at 16:59












it is preferred to use the "edit" link underneath the answer to update it, rather than adding separate comments.
– sourcejedi
Sep 5 at 17:53




it is preferred to use the "edit" link underneath the answer to update it, rather than adding separate comments.
– sourcejedi
Sep 5 at 17:53












The comment has nothing to do with the question, I'm expecting an answer of the "why don't you rather use tool XYZ", so I tried to avoid it :)
– lonix
Sep 5 at 18:29




The comment has nothing to do with the question, I'm expecting an answer of the "why don't you rather use tool XYZ", so I tried to avoid it :)
– lonix
Sep 5 at 18:29










2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










The instructions say:




Note: After editing /etc/fstab, (re)start the required service: systemctl daemon-reload && systemctl restart where <target> can be found by running systemctl list-unit-files --type automount




You have a problem :-(.



Mount options which are implemented by systemd, such as x-systemd.*, are not implemented by the mount command.



But the mount command is what you need to use, if you are an unprivileged user (no root/sudo), and you want to mount an fstab entry (which has been marked to allow this using the user or users mount option).






share|improve this answer






















  • I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
    – lonix
    Sep 5 at 18:27











  • Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
    – lonix
    Sep 6 at 6:03











  • One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
    – lonix
    Sep 6 at 7:07






  • 1




    But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
    – sourcejedi
    Sep 6 at 7:51






  • 1




    Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
    – lonix
    Sep 6 at 8:16


















up vote
1
down vote













The instructions are confusing, especially for someone who doesn't understand systemd.



The correct procedure:



  1. add to /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. run sudo systemctl daemon-reload. This creates a systemd "unit file".


  3. find out which unit file by running systemctl list-unit-files --type automount. For me it was mnt-remotes-hostname.automount.


  4. enable it: sudo systemctl restart mnt-remotes-hostname.automount.


  5. cd /mnt/remotes/hostname or ls /mnt/remotes/hostname and it will automatically create the sftp connection!


That works, but I'm not yet sure about:



  • some say allow_other is a security risk, I'll need to look into that

  • I don't know how to specify when the mount should be automatically unmounted (how many seconds of idle time, etc.)

If anyone can shed light on that, please do.




UPDATE
As per @sourcejedis's answer, stopping the mount must be done in this order: systemctl stop whatever.mount && systemctl stop whatever.automount and one should NOT use umount mounpoint!






share|improve this answer


















  • 1




    allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
    – sourcejedi
    Sep 5 at 20:43






  • 1




    x-systemd.idle-timeout= as per man systemd.mount
    – sourcejedi
    Sep 5 at 20:44










  • @sourcejedi Thanks for those missing pieces of the puzzle!
    – lonix
    Sep 6 at 5:56










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467081%2fsshfs-with-on-demand-mounting%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










The instructions say:




Note: After editing /etc/fstab, (re)start the required service: systemctl daemon-reload && systemctl restart where <target> can be found by running systemctl list-unit-files --type automount




You have a problem :-(.



Mount options which are implemented by systemd, such as x-systemd.*, are not implemented by the mount command.



But the mount command is what you need to use, if you are an unprivileged user (no root/sudo), and you want to mount an fstab entry (which has been marked to allow this using the user or users mount option).






share|improve this answer






















  • I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
    – lonix
    Sep 5 at 18:27











  • Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
    – lonix
    Sep 6 at 6:03











  • One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
    – lonix
    Sep 6 at 7:07






  • 1




    But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
    – sourcejedi
    Sep 6 at 7:51






  • 1




    Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
    – lonix
    Sep 6 at 8:16















up vote
1
down vote



accepted










The instructions say:




Note: After editing /etc/fstab, (re)start the required service: systemctl daemon-reload && systemctl restart where <target> can be found by running systemctl list-unit-files --type automount




You have a problem :-(.



Mount options which are implemented by systemd, such as x-systemd.*, are not implemented by the mount command.



But the mount command is what you need to use, if you are an unprivileged user (no root/sudo), and you want to mount an fstab entry (which has been marked to allow this using the user or users mount option).






share|improve this answer






















  • I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
    – lonix
    Sep 5 at 18:27











  • Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
    – lonix
    Sep 6 at 6:03











  • One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
    – lonix
    Sep 6 at 7:07






  • 1




    But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
    – sourcejedi
    Sep 6 at 7:51






  • 1




    Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
    – lonix
    Sep 6 at 8:16













up vote
1
down vote



accepted







up vote
1
down vote



accepted






The instructions say:




Note: After editing /etc/fstab, (re)start the required service: systemctl daemon-reload && systemctl restart where <target> can be found by running systemctl list-unit-files --type automount




You have a problem :-(.



Mount options which are implemented by systemd, such as x-systemd.*, are not implemented by the mount command.



But the mount command is what you need to use, if you are an unprivileged user (no root/sudo), and you want to mount an fstab entry (which has been marked to allow this using the user or users mount option).






share|improve this answer














The instructions say:




Note: After editing /etc/fstab, (re)start the required service: systemctl daemon-reload && systemctl restart where <target> can be found by running systemctl list-unit-files --type automount




You have a problem :-(.



Mount options which are implemented by systemd, such as x-systemd.*, are not implemented by the mount command.



But the mount command is what you need to use, if you are an unprivileged user (no root/sudo), and you want to mount an fstab entry (which has been marked to allow this using the user or users mount option).







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 5 at 20:55

























answered Sep 5 at 17:56









sourcejedi

20.3k42887




20.3k42887











  • I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
    – lonix
    Sep 5 at 18:27











  • Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
    – lonix
    Sep 6 at 6:03











  • One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
    – lonix
    Sep 6 at 7:07






  • 1




    But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
    – sourcejedi
    Sep 6 at 7:51






  • 1




    Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
    – lonix
    Sep 6 at 8:16

















  • I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
    – lonix
    Sep 5 at 18:27











  • Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
    – lonix
    Sep 6 at 6:03











  • One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
    – lonix
    Sep 6 at 7:07






  • 1




    But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
    – sourcejedi
    Sep 6 at 7:51






  • 1




    Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
    – lonix
    Sep 6 at 8:16
















I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
– lonix
Sep 5 at 18:27





I should have mentioned, I did that too - didn't help - systemctl daemon-reload && systemctl restart proc-sys-fs-binfmt_misc.automount
– lonix
Sep 5 at 18:27













Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
– lonix
Sep 6 at 6:03





Okay the order I issued the commands in was wrong (the instructions are confusing) and so I used the wrong unit file. I added a step by step answer to help anyone else. But you led me the right direction so thank you.
– lonix
Sep 6 at 6:03













One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
– lonix
Sep 6 at 7:07




One more thing: to unmount, is it correct to use unmount mountpoint or to use sudo systemctl stop mnt-remotes-hostname.automount? You mentioned systemd doesn't work with mount, so do I assume the same for umount? (both ways work, so I'm unsure which is safer/correct)
– lonix
Sep 6 at 7:07




1




1




But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
– sourcejedi
Sep 6 at 7:51




But I'm a bit worried about systemctl stop whatever.automount if you haven't already stopped the mount unit, after reading github.com/systemd/systemd/issues/6754
– sourcejedi
Sep 6 at 7:51




1




1




Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
– lonix
Sep 6 at 8:16





Ok so I'll always do systemctl stop whatever.mount && systemctl stop whatever.automount to be on the safe side, and never use umount. Thanks for the warning.
– lonix
Sep 6 at 8:16













up vote
1
down vote













The instructions are confusing, especially for someone who doesn't understand systemd.



The correct procedure:



  1. add to /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. run sudo systemctl daemon-reload. This creates a systemd "unit file".


  3. find out which unit file by running systemctl list-unit-files --type automount. For me it was mnt-remotes-hostname.automount.


  4. enable it: sudo systemctl restart mnt-remotes-hostname.automount.


  5. cd /mnt/remotes/hostname or ls /mnt/remotes/hostname and it will automatically create the sftp connection!


That works, but I'm not yet sure about:



  • some say allow_other is a security risk, I'll need to look into that

  • I don't know how to specify when the mount should be automatically unmounted (how many seconds of idle time, etc.)

If anyone can shed light on that, please do.




UPDATE
As per @sourcejedis's answer, stopping the mount must be done in this order: systemctl stop whatever.mount && systemctl stop whatever.automount and one should NOT use umount mounpoint!






share|improve this answer


















  • 1




    allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
    – sourcejedi
    Sep 5 at 20:43






  • 1




    x-systemd.idle-timeout= as per man systemd.mount
    – sourcejedi
    Sep 5 at 20:44










  • @sourcejedi Thanks for those missing pieces of the puzzle!
    – lonix
    Sep 6 at 5:56














up vote
1
down vote













The instructions are confusing, especially for someone who doesn't understand systemd.



The correct procedure:



  1. add to /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. run sudo systemctl daemon-reload. This creates a systemd "unit file".


  3. find out which unit file by running systemctl list-unit-files --type automount. For me it was mnt-remotes-hostname.automount.


  4. enable it: sudo systemctl restart mnt-remotes-hostname.automount.


  5. cd /mnt/remotes/hostname or ls /mnt/remotes/hostname and it will automatically create the sftp connection!


That works, but I'm not yet sure about:



  • some say allow_other is a security risk, I'll need to look into that

  • I don't know how to specify when the mount should be automatically unmounted (how many seconds of idle time, etc.)

If anyone can shed light on that, please do.




UPDATE
As per @sourcejedis's answer, stopping the mount must be done in this order: systemctl stop whatever.mount && systemctl stop whatever.automount and one should NOT use umount mounpoint!






share|improve this answer


















  • 1




    allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
    – sourcejedi
    Sep 5 at 20:43






  • 1




    x-systemd.idle-timeout= as per man systemd.mount
    – sourcejedi
    Sep 5 at 20:44










  • @sourcejedi Thanks for those missing pieces of the puzzle!
    – lonix
    Sep 6 at 5:56












up vote
1
down vote










up vote
1
down vote









The instructions are confusing, especially for someone who doesn't understand systemd.



The correct procedure:



  1. add to /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. run sudo systemctl daemon-reload. This creates a systemd "unit file".


  3. find out which unit file by running systemctl list-unit-files --type automount. For me it was mnt-remotes-hostname.automount.


  4. enable it: sudo systemctl restart mnt-remotes-hostname.automount.


  5. cd /mnt/remotes/hostname or ls /mnt/remotes/hostname and it will automatically create the sftp connection!


That works, but I'm not yet sure about:



  • some say allow_other is a security risk, I'll need to look into that

  • I don't know how to specify when the mount should be automatically unmounted (how many seconds of idle time, etc.)

If anyone can shed light on that, please do.




UPDATE
As per @sourcejedis's answer, stopping the mount must be done in this order: systemctl stop whatever.mount && systemctl stop whatever.automount and one should NOT use umount mounpoint!






share|improve this answer














The instructions are confusing, especially for someone who doesn't understand systemd.



The correct procedure:



  1. add to /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. run sudo systemctl daemon-reload. This creates a systemd "unit file".


  3. find out which unit file by running systemctl list-unit-files --type automount. For me it was mnt-remotes-hostname.automount.


  4. enable it: sudo systemctl restart mnt-remotes-hostname.automount.


  5. cd /mnt/remotes/hostname or ls /mnt/remotes/hostname and it will automatically create the sftp connection!


That works, but I'm not yet sure about:



  • some say allow_other is a security risk, I'll need to look into that

  • I don't know how to specify when the mount should be automatically unmounted (how many seconds of idle time, etc.)

If anyone can shed light on that, please do.




UPDATE
As per @sourcejedis's answer, stopping the mount must be done in this order: systemctl stop whatever.mount && systemctl stop whatever.automount and one should NOT use umount mounpoint!







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 6 at 8:18

























answered Sep 5 at 19:25









lonix

31719




31719







  • 1




    allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
    – sourcejedi
    Sep 5 at 20:43






  • 1




    x-systemd.idle-timeout= as per man systemd.mount
    – sourcejedi
    Sep 5 at 20:44










  • @sourcejedi Thanks for those missing pieces of the puzzle!
    – lonix
    Sep 6 at 5:56












  • 1




    allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
    – sourcejedi
    Sep 5 at 20:43






  • 1




    x-systemd.idle-timeout= as per man systemd.mount
    – sourcejedi
    Sep 5 at 20:44










  • @sourcejedi Thanks for those missing pieces of the puzzle!
    – lonix
    Sep 6 at 5:56







1




1




allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
– sourcejedi
Sep 5 at 20:43




allow_other should not allow privilege escalation, only denial of service (cause process to hang, it can be killed though). I wouldn't enable it if you don't want the feature it provides, but if you do then I would just do it :-).
– sourcejedi
Sep 5 at 20:43




1




1




x-systemd.idle-timeout= as per man systemd.mount
– sourcejedi
Sep 5 at 20:44




x-systemd.idle-timeout= as per man systemd.mount
– sourcejedi
Sep 5 at 20:44












@sourcejedi Thanks for those missing pieces of the puzzle!
– lonix
Sep 6 at 5:56




@sourcejedi Thanks for those missing pieces of the puzzle!
– lonix
Sep 6 at 5:56

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467081%2fsshfs-with-on-demand-mounting%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?