sftp

sshfs

  • if the user wants to mount a folder of remote ssh enabled server into the local directory tree, this is probably the way to go
  • is way easier and super secure way to mount folders of remote servers
  • all it needs is a ssh server on the server
    • no need for service side config
  • while security is good (login, transfer encrypted) performance might be less than samba or a direct (PC1<-LAN->PC2) NFS connection (NFS should not be used in any other way because of security issues) and also smb should probably not be used over internet without a VPN or other encrypted tunneling technology

debugging errors:

# it should be possible to give non-root access to the sshfs mounted folder
# make sure the user has the same USERID:GROUPID on client and server

hostnamectl; # tested on 
Static hostname: workstation
Operating System: Debian GNU/Linux 13 (trixie) 
Kernel: Linux 6.12.74+deb13+1-amd64
Architecture: x86-64

sshfs --version
SSHFS version 3.7.3
FUSE library version 3.17.2
using FUSE kernel interface version 7.40
fusermount3 version: 3.17.2

hostnamectl; # system tested with client and server
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 4.19.0-14-amd64
Architecture: x86-64

sshfs --version
SSHFS version 2.10.0
FUSE library version: 2.9.9
fusermount version: 2.9.9
using FUSE kernel interface version 7.19

# what userid has the non-root user?
id -u
1000

# become root
su - root;

# deb based installation of the package
apt install sshfs
# for CentOS8 checkout this guide
# how to enable power tools repo
yum install fuse-sshfs.x86_64

# as root create mount point
# this is perfect for GNU Linux (Debian) desktop gui users
mkdir -p /media/user/sshfs

# this is perfect for GNU Linux (rpm/Fedora/CentOS/Redhat) desktop gui users
mkdir -p /run/media/user/sshfs
# hand over ownership of mount point to default-non-root user
chown -R user:user /media/user/sshfs

# as non-root user (!) try to mount
sshfs -o allow_other,default_permissions root@ip.of.server.ssh:/mount/this/folder /media/user/sshfs

# as non-root user (!) alternatively try to mount
# this sets access rights in a way that gives non root (uid=1000 and gid=1000) easy access
sshfs user@ip.of.server.ssh:/mount/this/folder/ /media/user/sshfs/ -o allow_other -o idmap=user -o uid=1000 -o gid=1000

# if it complains
fuse: unknown option `idmap=user'
# just leave out -o idmap=user

# if it complains: fusermount3: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf
# make sure to uncomment this
# then retry mount command
vim /etc/fuse.conf
# The file /etc/fuse.conf allows for the following parameters:
#
# user_allow_other - Using the allow_other mount option works fine as root, but
# in order to have it work as a regular user, you need to set user_allow_other
# in /etc/fuse.conf as well. This option allows non-root users to use the
# allow_other option. You need allow_other if you want users other than the
# owner of a mounted fuse to access it. This option must appear on a line by
# itself. There is no value; just the presence of the option activates it.

# user_allow_other

# mount_max = n - this option sets the maximum number of mounts.
# It must be typed exactly as shown (with a single space before and after the
# equals sign).

#mount_max = 1000
# how to put this into fstab for auto mount on boot?
user@ip.of.server.ssh:/mount/this/folder/ /media/user/sshfs/ fuse.sshfs allow_other,idmap=user,uid=1000,gid=1000,_netdev 0 0

manpages:

Links:

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin