[Nix-dev] systemd + sshfs

Rickard Nilsson rickard.nilsson at telia.com
Sun Sep 18 23:19:58 CEST 2016


Hi Bjørn,

I remember struggling with this too. The following works for me:

fileSystems."/target" =
   fsType = "fuse";
   device = "${pkgs.sshfsFuse}/bin/sshfs#user at host:/path";
   options = [
     "noauto" "comment=systemd.automount"
     "ssh_command=${sshAsUser}"
   ];
};

where

   sshAsUser = user:
     writeScript "ssh_as_${user}" ''
       exec ${pkgs.sudo}/bin/sudo -i -u ${user} \
         ${pkgs.openssh}/bin/ssh $@
     '';

The "sshAsUser" command makes systemd use my gpg-agent session correctly 
when auto-mounting. But I guess you could use it to set any ssh options 
you'd like.

   / Rickard

On 09/18/2016 06:10 PM, Bjørn Forsman wrote:
> Hi all,
>
> I cannot get systemd to find the 'sshfs' binary needed to make this
> configuration work:
>
>   systemd.mounts = [
>     { what = "bfo at whitetip.local:/";
>       where = "/home/bfo/mnt/whitetip.local";
>       type = "fuse.sshfs";
>       options =
> "_netdev,users,idmap=user,IdentityFile=/home/user/.ssh/id_rsa,allow_other,reconnect";
>       unitConfig.Environment = "PATH=${pkgs.sshfsFuse}/bin";
>     }
>   ];
>
> The result is "/bin/sh: sshfs: command not found", as can be seen
> below my signature.
>
> Any suggestions?
>



More information about the nix-dev mailing list