How to connect to remote servers with SSH and Netatalk?

If you setup public/private keys, then no password will be transmitted, only the public key. You can copy your osmc user key to the root user on the NAS, so you would be able to use root@mynas.com.

If your NAS does not allow you to create new users, then you are probably stuck with using root. If the NAS does have other users, then copy the key to that user on the NAS. Do some googling on how SSH works (everything you learn about SSH also pertains to SSHFS)

FMHO I would just get another RPi (there should be cheap used RPi1 out there) and install openvpn, then your OSMC travelling around with you always will behave as if it would be at home.

If there’s demand for AFP, I could look at re-adding it

I have installed it from source on my Raspberry Pi. It’s not too much work to do but a package is certainly welcome :-).

I know this is a really old topic. I’ve just setup an FTP server that I access over the internet and am able to mount it manually using SSHFS. However, my initial pass adding it to /etc/fstab sent me to recovery mode upon reboot. At the risk of losing access, do you have an example etc/fstab entry that I could review? Thanks!

First, did you have a look at this: [HOW-TO] SSHFS tutorial

You need to have your public/private keys setup properly. If so, something like this should work:

osmc@ip.of.server: /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 0 0

Try to manually mount it before rebooting for testing, but since noauto and autmount are used even if you get the entry in fstab wrong it won’t prevent your system from booting.

Thanks for your reply.

The ftp server is on a shared host that does not provide root access. As such, I’m not able to create the user osmc on the server nor edit /etc/ssh/sshd_config on the server side.

When I include the following in /etc/fstab and reboot

remoteusername@ip.of.server: /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 0 0

the output of
osmc@osmc:~$ ls -al /mnt/sshfsmount/

returns
ls: cannot access '/mnt/sshfsmount/': No such device

I am able to manually mount as follows:
osmc@osmc:~$ sshfs -o idmap=user,allow_other,nonempty remoteusername@ip.of.server: /mnt/sshfsmount

When doing so, the output of
ls -al /mnt/sshfsmount/
returns the directory structure shown below with osmc as the user and permissions preserved.

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 14 20:42 ..
-rw-r--r-- 1 osmc 1903  269 Feb 12 21:37 .bash_aliases
-rw------- 1 osmc 1903 7850 Feb 15 09:10 .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
drwxr-xr-x 1 osmc 1903 4096 Feb 12 21:37 www

I am able to read and write files in that directory as the osmc user.

Further thoughts regarding etc/fstab?

Did you setup your keys? If you:

ssh remoteusername@ip.of.server

do you get prompted for a password? If so, you didn’t setup your keys properly yet and fstab will not work.

Yes, the keys have been setup.
osmc@osmc:~$ ssh remoteusername@ip.of.server
logs in to the server without a password prompt.

Ok, did you create the directory /mnt/sshfsmount? (Needs to be an empty directory).

What happens if you just

sudo mount /etc/sshfsmount

does the file: /home/osmc/.ssh/id_rsa exist, and what are its permissions? (on the Pi)

Instead of gid=1000,uid=1000 in fstab, you could try the idmap=user option, but I doubt that’s the problem.

/mnt/sshfsmount/ exists and is empty.

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 /etc/sshfsmount
mount: can't find /etc/sshfsmount in /etc/fstab
osmc@osmc:~$ ls -al /home/osmc/.ssh/id_rsa
-rw------- 1 osmc osmc 1675 Mar 11  2018 /home/osmc/.ssh/id_rsa

When I include the option idmap=user the following is returned

osmc@osmc:~$ sudo mount -av
/mnt/sshfsmount            : ignored

Thanks again for your help.

Sorry, that was a typo on my part:

sudo mount /mnt/sshfsmount

To test the mountpoint, I did the following:

osmc@osmc:~$ sudo umount /mnt/sshfsmount
umount: /mnt/sshfsmount: not mounted

then I confirmed the following entry was in /etc/fstab
remoteusername@ip.of.server:/media/sshfsmount/ /mnt/sshfsmount fuse.sshfs x-systemd.automount,x-systemd.requires=network.target,x-systemd.after=network-online.target,noauto,rw,idmap=user,transform_symlinks,identityfile=/home/osmc/.ssh/id_rsa,allow_other,default_permissions 0 0

and ran the following

osmc@osmc:~$ sudo mount -av
/mnt/sshfsmount        : ignored
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
osmc@osmc-turtle:~$ ls -al /mnt/sshfsmount/
ls: cannot open directory '/mnt/sshfsmount/': Permission denied

Thanks!

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.