You are not logged in.

#1 2015-07-19 05:22:19

jonnsl
Member
Registered: 2015-01-11
Posts: 22

Automounting sshfs on demand using systemd not working.

I tried to setup automount on demand of a sshfs according to the wiki, but every time I try to access it, Nautilus gives me this error:

This location could not be displayed.
Sorry, could not display all the contents of “htpc”: No such device

journalctl -u mnt-htpc.automount -u mnt-htpc.mount

Jul 19 01:56:26 localhost systemd[1]: Set up automount mnt-htpc.automount.
Jul 19 01:56:26 localhost systemd[1]: Starting mnt-htpc.automount.
Jul 19 01:57:03 localhost systemd[1]: mnt-htpc.automount: Got automount request for /mnt/htpc, triggered by 5710 (pool)
Jul 19 01:57:03 localhost systemd[1]: Mounting /mnt/htpc...
Jul 19 01:57:03 localhost systemd[1]: Mounted /mnt/htpc.
Jul 19 01:57:03 localhost mount[5712]: read: Connection reset by peer
Jul 19 01:57:03 localhost systemd[1]: mnt-htpc.mount: Mount process exited, code=exited status=1
Jul 19 01:57:03 localhost systemd[1]: mnt-htpc.mount: Unit entered failed state.
Jul 19 01:57:03 localhost systemd[1]: mnt-htpc.automount: Got automount request for /mnt/htpc, triggered by 5243 (nautilus)
Jul 19 01:57:03 localhost systemd[1]: Mounting /mnt/htpc...
Jul 19 01:57:03 localhost systemd[1]: Mounted /mnt/htpc.
Jul 19 01:57:04 localhost mount[5719]: read: Connection reset by peer
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.mount: Mount process exited, code=exited status=1
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.mount: Unit entered failed state.
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.automount: Got automount request for /mnt/htpc, triggered by 5710 (pool)
Jul 19 01:57:04 localhost systemd[1]: Mounting /mnt/htpc...
Jul 19 01:57:04 localhost systemd[1]: Mounted /mnt/htpc.
Jul 19 01:57:04 localhost mount[5727]: read: Connection reset by peer
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.mount: Mount process exited, code=exited status=1
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.mount: Unit entered failed state.
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.automount: Got automount request for /mnt/htpc, triggered by 5246 (gmain)
Jul 19 01:57:04 localhost systemd[1]: Mounting /mnt/htpc...
Jul 19 01:57:04 localhost systemd[1]: Mounted /mnt/htpc.
Jul 19 01:57:04 localhost mount[5736]: read: Connection reset by peer
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.mount: Mount process exited, code=exited status=1
Jul 19 01:57:04 localhost systemd[1]: mnt-htpc.mount: Unit entered failed state.
ExecMount=/usr/bin/mount jonnathan@192.168.1.150:/home/jonnathan /mnt/htpc -n -t fuse.sshfs -o x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/jonnathan/.ssh/id_rsa,allow_other,reconnect

/etc/fstab

jonnathan@192.168.1.150:/home/jonnathan /mnt/htpc  fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/jonnathan/.ssh/id_rsa,allow_other,reconnect 0 0

If I try to execute the ExecMount in a shell, it works successfully, but I get asked for the password to unlock my private key. If I mount using `sshfs jonnathan@192.168.1.150:/home/jonnathan /mnt/htpc` without sudo, I don't even get asked for a password, as gnome-keyring/seahorse is set to unlock my private key on login.

My guess is that the mount command can't ask me for a password because is not running in a terminal so the connection gets reset.
Is that really the problem? if so, how do I instruct the systemd/mount or whatever to use the gnome-keyring?

Offline

#2 2015-07-23 23:42:57

zidarsk8
Member
Registered: 2011-12-06
Posts: 97

Re: Automounting sshfs on demand using systemd not working.

This is not really a solution, but you should try to make a passwordless ssh key for your user and your sudo user. That's how you can make sure that your problem is actually the unlocking of the key itself, and not something else.

Offline

#3 2015-07-28 12:29:09

jonnsl
Member
Registered: 2015-01-11
Posts: 22

Re: Automounting sshfs on demand using systemd not working.

I tested with a passwordless key and indeed the password seems to be the problem. anyway, I found a solution. It's ugly but it works (kind of).
first I removed that line from /etc/fstab. then I created these two files:

/etc/systemd/system/mnt-htpc.automount

[Automount]
Where=/mnt/htpc

[Install]
WantedBy=remote-fs.target

/etc/systemd/system/mnt-htpc.mount

[Mount]
What=jonnathan@192.168.1.150:/home/jonnathan
Where=/mnt/htpc
Type=fuse.sshfs
Options=noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/jonnathan/.ssh/id_rsa,allow_other,reconnect
Environment="SSH_AUTH_SOCK=/run/user/1000/keyring/ssh"

then I enabled  it.

# systemctl enable mnt-htpc.automount

but now the SSH_AUTH_SOCK variable is randomly unset in my environment, not sure if related.

Offline

Board footer

Powered by FluxBB