How to connect to remote servers with SSH and Netatalk?

Hi,

If the above works, I would try simplifying the fstab entry:

remoteusername@ip.of.server:/media/sshfsmount/ /mnt/sshfsmount fuse.sshfs x-systemd.automount,noauto,rw,idmap=user,allow_other,nonempty,transform_symlinks,identityfile=/home/osmc/.ssh/id_rsa 0 0

If still having issues, please issue:

sudo mount -v sudo mount -v

and post the output here.

Thanks Tom.

Hi Tom, thanks for chiming in.

I executed the following, with output displayed. To summarize, yes, I’m able to manually mount via the line you suggested but the mount point gets ignored when mounting via /etc/fstab.

osmc@osmc:~$ sudo umount /mnt/sshfsmount
osmc@osmc:~$ ls -al /mnt/sshfsmount
total 8
drwxr-xr-x 2 osmc osmc 4096 Feb 17 08:03 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
osmc@osmc-turtle:~$ sshfs -o idmap=user,allow_other,nonempty remoteusername@ip.of.server:/media/sshfsmount/ /mnt/sshfsmount
osmc@osmc:~$ ls -al /mnt/sshfsmount/                                                                                                                                                                      total 68
drwx------ 1 osmc 1903 4096 Feb 13 11:30 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
-rw-r--r-- 1 osmc 1903  269 Feb 12 21:37 .bash_aliases
-rw------- 1 osmc 1903 7899 Feb 15 23:05 .bash_history
-rw-r--r-- 1 osmc 1903  220 Feb 12 21:37 .bash_logout
-rw-r--r-- 1 osmc 1903   42 Feb 12 21:37 .bashrc
drwx------ 1 osmc 1903 4096 Feb 12 21:42 .config
drwx------ 1 osmc 1903 4096 Feb 12 22:25 .nano
drwxr-xr-x 1 osmc 1903 4096 Feb 13 00:32 .nginx
-rw-r--r-- 1 osmc 1903  677 Feb 12 21:37 .profile
-rw-r--r-- 1 osmc 1903 1061 Feb 13 00:32 .rtorrent.rc
drwx------ 1 osmc 1903 4096 Feb 13 07:42 .ssh
drwx------ 1 osmc 1903 4096 Feb 12 23:18 Downloads
-rw------- 1 osmc 1903 1329 Feb 13 22:25 action.log
drwxr-xr-x 1 osmc 1903 4096 Feb 13 00:32 private
osmc@osmc:~$ sudo umount /mnt/sshfsmount
osmc@osmc:~$ ls -al /mnt/sshfsmount/
total 8
drwxr-xr-x 2 osmc osmc 4096 Feb 17 08:03 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
osmc@osmc:~$ sudo mount -av
/mnt/media                 : ignored      # <--- SAMBA/CIFS share on local network
/mnt/sshfsmount            : ignored
osmc@osmc:~$ sudo mount -v
devtmpfs on /dev type devtmpfs (rw,relatime,size=791584k,nr_inodes=197896,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /run type tmpfs (rw,relatime)
/dev/mapper/vero--nand-root on / type ext4 (rw,relatime,stripe=1024,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/bfqio type cgroup (rw,nosuid,nodev,noexec,relatime,bfqio)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
systemd-1 on /mnt/media type autofs (rw,relatime,fd=47,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
//192.168.0.1/Seagate_Expansion_Drive/Media on /mnt/media type cifs (rw,relatime,vers=1.0,sec=ntlm,cache=strict,uid=1000,forceuid,gid=0,noforcegid,addr=192.168.0.1,unix,posixpaths,serverino,acl,rsize=61440,wsize=65536,actimeo=1)
/dev/mapper/vero--nand-root on /var/lib/docker/aufs type ext4 (rw,relatime,stripe=1024,data=ordered)
none on /var/lib/docker/aufs/mnt/877c796b808d953f9f25d0475c8d97602492a1f874fae6666cdacecf127f8208 type aufs (rw,relatime,si=da0eb17592cfd597,dio,dirperm1)
shm on /var/lib/docker/containers/a4cbb6a6ac71691bea1f7dca556ab75c532452e20cbafa65a5c0ac7f230ea12d/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=65536k)
proc on /run/docker/netns/c1506ebae9b8 type proc (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=183224k,mode=700,uid=1000,gid=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)

Did you do as @Tom_Doyle suggested and simplified the fstab line to match the options in your manual mount?

BTW, I tested the idmap=user option and it doesn’t work. Use uid=1000,gid=1000 instead.

I did try @Tom_Doyle’s suggestions. See my last post.
I also replaced idmap=user with uid=1000,gid=1000 in /etc/fstab. The relevant entry is now:

remoteusername@ip.of.server:/media/sshfsmount/ /mnt/sshfsmount fuse.sshfs x-systemd.automount,noauto,rw,uid=1000,gid=1000,allow_other,nonempty,transform_symlinks,identityfile=/home/osmc/.ssh/id_rsa 0 0

with the same results.

Interestingly, I just noticed that upon reboot, although the mount point gets ignored, the ownership of the mount changes to root.

Unmounted:

osmc@osmc:~$ sudo umount /mnt/sshfsmount
umount: /mnt/sshsmount: not mounted
osmc@osmc:~$ ls -al /mnt
total 12
drwxr-xr-x  4 root root 4096 Feb 17 08:03 .
drwxr-xr-x 24 root root 4096 Feb 14 21:59 ..
drwxr-xr-x  2 osmc osmc 4096 Feb 17 08:03 sshfsmount

After reboot:

osmc@osmc:~$ ls -al /mnt
total 8
drwxr-xr-x  4 root root 4096 Feb 17 08:03 .
drwxr-xr-x 24 root root 4096 Feb 14 21:59 ..
drwxr-xr-x  2 root root    0 Nov  3  2016 sshfsmount

I can confirm that this behavior occurs with both idmap=user in etc/fstab and after replacing idmap=user with uid=1000,gid=1000. Does this suggest the permissions aren’t getting set properly via /etc/fstab? Almost as if the uid/gid permissions are getting ignored??

Is the location of the files on the remote server really /media/sshfsmount? You were using just the home of remoteusername previously.

I should clarify, I named the mount directory on my local system the same as remoteusername.
So in this topic, remoteusername = sshfsmount. Probably causes some confusion. I’ll clean that up from here on out.

With either
osmc@osmc:~$ sftp remoteusername@ip.of.server
or
osmc@osmc:~$ sftp remoteusername@ip.of.server:/media/remoteusername
the output of
sftp> ls -al
displays the same directory contents. Ownership of each of the directory content items is remoteusername:remoteusername.
I assume there’s some redirect happening but can’t confirm.

I’ve tried both ways in /etc/fstab and manually with the same results as described. (Without the trailing / in the former.)

That’s because then you are connected via sftp you are running the command on the server so will see the uid/gid names as defined on the server.

I don’t think this will help, but it’s worth trying. Try with these options:

remoteusername@ip.of.server:/media/sshfsmount/ /mnt/sshfsmount fuse.sshfs x-systemd.automount,noauto,rw,user,transform_symlinks,identityfile=/home/osmc/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000

Other than the paths, that’s the exact line I’m testing with in fstab and it works perfect.

After reboot, I see the same as before, no joy.

osmc@osmc:~$ ls -al /mnt/sshfsmount/
ls: cannot access '/mnt/sshfsmount/': No such device

I’m at a loss at this point. When I’ve seen that error in the past it’s either the path being mounted on the server is incorrect/invalid, or the ssh keys are not properly working.

Another longshot idea, remove the identityfile= bit from the options. Don’t reboot, but manually try to mount.

sudo mount /mnt/sshfsmount

It should prompt you for your password.

Well that’s interesting. I jumped the gun and did not immediately remove the identityfile= option. Rather, I left /etc/fstab as before

remoteusername@ip.of.server:/media/sshfsmount/ /mnt/sshfsmount fuse.sshfs x-systemd.automount,noauto,rw,user,transform_symlinks,identityfile=/home/osmc/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000

and rebooted. Then I executed the following:

osmc@osmc:~$ sudo umount /mnt/sshfsmount
osmc@osmc:~$ ls -al /mnt/sshfsmount/
total 8
drwxr-xr-x 2 osmc osmc 4096 Feb 17 08:03 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
osmc@osmc:~$ sudo mount /mnt/sshfsmount

and the directory mounts properly

osmc@osmc:~$ ls -al /mnt/sshfsmount/
total 68
drwx------ 1 osmc osmc 4096 Feb 13 11:30 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
-rw-r--r-- 1 osmc osmc  269 Feb 12 21:37 .bash_aliases
-rw------- 1 osmc osmc 7899 Feb 15 23:05 .bash_history
-rw-r--r-- 1 osmc osmc  220 Feb 12 21:37 .bash_logout
-rw-r--r-- 1 osmc osmc   42 Feb 12 21:37 .bashrc
drwx------ 1 osmc osmc 4096 Feb 12 21:42 .config
drwx------ 1 osmc osmc 4096 Feb 12 22:25 .nano
drwxr-xr-x 1 osmc osmc 4096 Feb 13 00:32 .nginx
-rw-r--r-- 1 osmc osmc  677 Feb 12 21:37 .profile
-rw-r--r-- 1 osmc osmc 1061 Feb 13 00:32 .rtorrent.rc
drwx------ 1 osmc osmc 4096 Feb 13 07:42 .ssh
drwx------ 1 osmc osmc 4096 Feb 12 23:18 Downloads
-rw------- 1 osmc osmc 1329 Feb 13 22:25 action.log
drwxr-xr-x 1 osmc osmc 4096 Feb 13 00:32 private
drwxr-xr-x 1 osmc osmc 4096 Feb 12 21:37 www

I then followed your suggestion and removed identityfile=, then unmounted to test. After reboot I executed the following:

osmc@osmc:~$ sudo umount /mnt/sshfsmount
osmc@osmc:~$ ls -al /mnt/sshfsmount/
total 8
drwxr-xr-x 2 osmc osmc 4096 Feb 17 08:03 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
osmc@osmc:~$ sudo mount /mnt/sshfsmount
remoteusername@ip.of.server's password:    # <---- password was entered

and the directory contents of the remote server were successfully accessible.

osmc@osmc:~$ ls -al /mnt/sshfsmount/
total 68
drwx------ 1 osmc osmc 4096 Feb 13 11:30 .
drwxr-xr-x 4 root root 4096 Feb 17 08:03 ..
-rw-r--r-- 1 osmc osmc  269 Feb 12 21:37 .bash_aliases
-rw------- 1 osmc osmc 7899 Feb 15 23:05 .bash_history
-rw-r--r-- 1 osmc osmc  220 Feb 12 21:37 .bash_logout
-rw-r--r-- 1 osmc osmc   42 Feb 12 21:37 .bashrc
drwx------ 1 osmc osmc 4096 Feb 12 21:42 .config
drwx------ 1 osmc osmc 4096 Feb 12 22:25 .nano
drwxr-xr-x 1 osmc osmc 4096 Feb 13 00:32 .nginx
-rw-r--r-- 1 osmc osmc  677 Feb 12 21:37 .profile
-rw-r--r-- 1 osmc osmc 1061 Feb 13 00:32 .rtorrent.rc
drwx------ 1 osmc osmc 4096 Feb 13 07:42 .ssh
drwx------ 1 osmc osmc 4096 Feb 12 23:18 Downloads
-rw------- 1 osmc osmc 1329 Feb 13 22:25 action.log
drwxr-xr-x 1 osmc osmc 4096 Feb 13 00:32 private
drwxr-xr-x 1 osmc osmc 4096 Feb 12 21:37 www

So it appears obvious that the RSA keys are loading correctly. I find it interesting that in the first part of this post I’m able to mount without any options in the mount command. It’s as if the options had been preloaded via /etc/fstab upon reboot but there’s some error preventing the remote server to mount automatically. Could it be a timing issue? Perhaps with the network? I’m just spitballing and at a loss.

I don’t understand what’s happening either. I suspect like you that it’s a timing issue.

Here is another idea, instead of using fstab mounts switch over to using autofs mounts. I have found that autofs works much better if you have systems that are not always online vs systemd mounts.

Have a look here to get started: Mounting network shares with autofs (alternative to fstab)

An example of what a autofs map would look like:

/mnt/sshfsmount -fstype=fuse,rw,uid=1000,gid=1000,allow_other,identityfile=/home/osmc/.ssh/id_rsa :sshfs\#remoteuser@remote.ip.address\:

The backslashes and # are not mistakes, they are needed. I use this on my laptop and it works fine. I never really used the fstab version other than for testing for other users and occasional manual mounting. With autofs it just mounts when I need it.

1 Like

Funny, before I saw your post I started exploring autofs. Great minds…

The following was SUCCESSFUL:

sudo nano /etc/auto.master

add the following to the end of that file:

/- /etc/auto.sshfs.shares --timeout 15 browse

then map the share

sudo nano /etc/auto.sshfs.shares

with the following entry

/mnt/sshfsmount -fstype=fuse,noauto,idmap=user,allow_other,nonempty,identityfile=/home/osmc/.ssh/id_rsa,uid=1000,gid=1000 :sshfs\#remoteusername@remote.ip.address\:/media/directorytomap

Everything mounts properly, with the correct permissions. I no longer have any shares mounted via /etc/fstab. I removed the entry for a SMB share and created an autofs entry for that as well, per the linked discussion. Perfect solution.

Thanks so much for pointing me in the right direction.

Great news! One more reason why we should point people to use autofs in instead of fstab!

1 Like

+1