Configure sshfs without a shell user.
1. Create a user without a shell and set a password for him:
# useradd -m "sshfsuser" -s /usr/sbin/nologin
# passwd sshfsuser
2. Open /etc/ssh/sshd_config and find the line:
Subsystem sftp /usr/lib/openssh/sftp-server
Change it to:
Subsystem sftp internal-sftp
Also at the end of this file append the following:
Match User sshfsuser
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
3. Restart ssh daemon:
# systemctl restart ssh
4. Change the ownership of the user's home directory. It must be owned by root for chroot to work:
# chown root:root /home/sshfsuser
5. Create a directory which sshfs will mount and change ownership:
# mkdir /home/sshfsuser/sshfs_dir
# chown sshfsuser: /home/sshfsuser/sshfs_dir
6. On remote server create a directory and mount sshfs there:
# mkdir /root/sshfs_dir
# sshfs sshfsuser@server_ip_here:/sshfs_dir /root/sshfs_dir
7. Check mounting:
# df -h
You also can configure fstab, key-based authentication, etc.