You are not logged in.

#1 2022-10-02 02:23:53

G4Zz0L1
Member
Registered: 2021-02-11
Posts: 3

[SOLVED] SSHFS on fstab for a Synology NAS

Hi guys,
I've been a fellow arch user for a lot of years, so don't go easy on me, I can take it!   big_smile
English is not my native language, please excuse eventual typing errors.
I've never written here, mainly because I've always solved my problems by reading the wiki and the various posts in the forum, but this one is far beyond me and my searching skills.
I have a strange problem in trying to auto-mount my Synology with SSHFS with keys, and the relevant /etc/fstab entry.
Arch is updated, as always here, and everything works fine on its own.
The strange thing is that this works (both user and root):

ssh g4zz0l1@g4zz0l1-nas

this works (again, both user and root) and correctly mounts the folder:

sshfs g4zz0l1@g4zz0l1-nas:/home /media/NAS

this entry on /etc/fstab doesn't:

g4zz0l1@g4zz0l1-nas:/home /media/NAS fuse.sshfs defaults,_netdev 0 0

I've tried a bunch of options, like "users", "allow_other", "idmap=user", "IdentityFile=/home/g4zz0l1/.ssh/id_ed25519", removing "defaults" and so on, but most of what I'm reading is for permissions error with reading/writing files.
I've also tried to translate the host with the ip, and checked the various points on the troubleshooting section in the ssh and sshfs pages on the wiki.
With the "sshfs_debug,debug" parameters this shows up on the journal:

2022-10-02 03:36:17.000000 systemd[1]: Mounting /media/NAS...
2022-10-02 03:36:17.000000 mount[3015966]: SSHFS version 3.7.3
2022-10-02 03:36:17.000000 mount[3015968]: executing <ssh> <-x> <-a> <-oClearAllForwardings=yes> <-2> <g4zz0l1@g4zz0l1-nas> <-s> <sftp>
2022-10-02 03:36:25.000000 mount[3015968]: Permission denied, please try again.
2022-10-02 03:36:34.000000 mount[3015968]: Permission denied, please try again.
2022-10-02 03:36:42.000000 mount[3015968]: g4zz0l1@g4zz0l1-nas: Permission denied (publickey,password).
2022-10-02 03:36:42.000000 mount[3015966]: read: Connection reset by peer
2022-10-02 03:36:42.000000 systemd[1]: media-NAS.mount: Mount process exited, code=exited, status=1/FAILURE
2022-10-02 03:36:42.000000 systemd[1]: media-NAS.mount: Failed with result 'exit-code'.
2022-10-02 03:36:42.000000 systemd[1]: Failed to mount /media/NAS.

I've even tried to mimic the commands with a systemd unit (both user and root), with the same results.
AFAIK this error pops up when there are wrong permission on the .ssh folder on the server or the host, but then the manual command should fail too.
The only thing that I don't know how to fix is the sftp subsystem on the Synology which is set to:

Subsystem sftp internal-sftp -f DAEMON -u 000

but again, the manual command should fail with that if it was wrong, right?
Even with that, on the Synology with a find for anything "sftp" related from the /, I can't find a binary for another subsystem in the usual folders (like /usr/lib or /usr/libexec).
I've read the pages on the wiki on the involved subjects and half google, but nothing works so far so this is my last shot.
What am I missing here?
Anybody got ideas for more tests I can run to pin down the problem?
Let me know if you need something else to test this, and thanks in advance!

Last edited by G4Zz0L1 (2022-10-03 16:44:14)

Offline

#2 2022-10-02 06:39:29

-thc
Member
Registered: 2017-03-15
Posts: 485

Re: [SOLVED] SSHFS on fstab for a Synology NAS

To be honest with you - I'm a little baffled by your questions.

sftp is convenient for transferring files to a host that has no other accessible ports/services available - I use it to transfer small files (config, scripts, keys) to "ssh only" linux boxes.

For sshfs/fstab to work you have to use password-less public-key authentication via files (~/.ssh) inside the home directories of the ssh server.

Synology NAS sshd is disabled by default (hint 1).

Synology NAS ssh access is restricted to members of the administrators group of DSM (hint 2).

The /etc/passwd on Synology NAS points to home directories that are non-existent (/var/package/homes/username) for non-root users (hint 3).

In short - ssh on Synology NAS is unusable for your purpose (and IMHO should not be used anyway).

Why are you not using NFS for this? It works flawlessly with my Arch boxes and my Synology NAS.

Offline

#3 2022-10-02 12:39:46

G4Zz0L1
Member
Registered: 2021-02-11
Posts: 3

Re: [SOLVED] SSHFS on fstab for a Synology NAS

That's exactly what I'm hoping to achieve.
Password-less public-key sshfs authentication via /etc/fstab.
I've enabled sshd, and the homes folder on the Synology and everything works fine, If called manually with ssfhs.
SSH is perfectly usable on the Synology, if enabled correctly.
The baffling part is that everything works fine, if called manually, but gives the error above if called from /etc/fstab.
I don't like NFS mainly because it's non encrypted, I would prefer to get it to work with sshfs, if possbile.

Last edited by G4Zz0L1 (2022-10-02 12:40:34)

Offline

#4 2022-10-03 08:06:52

-thc
Member
Registered: 2017-03-15
Posts: 485

Re: [SOLVED] SSHFS on fstab for a Synology NAS

I tested your setup against a "real" SSH server (Debian) and this fstab entry works fine:

USERNAME@IP_ADDRESS:/home/USERNAME /mnt/test fuse.sshfs _netdev,user,identityfile=/home/USERNAME/.ssh/id_ed25519,allow_other 0 0

Offline

#5 2022-10-03 16:43:05

G4Zz0L1
Member
Registered: 2021-02-11
Posts: 3

Re: [SOLVED] SSHFS on fstab for a Synology NAS

Thanks, I also tried your way, but returns the same error.
Interestingly, one thing that I haven't tried before, if I do a manual mount as root it works, but asks for the key password, even the root one.
In the end the problem was that the SSH agent was not configured correctly for root (having never used it).
After activated and configured ssh-agent for root, everything seems ok.
Thanks for the help and for the ideas, marking as solved!
Bye!

Offline

Board footer

Powered by FluxBB