DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

chroot SFTP User and Bind Mount in Linux

August 9, 2020 DbAppWeb Admin

Problem

I have created a chroot SFTP user with home directory /incoming, Now I have to share the files contained in the folder /home/documents/pdf. Documents in directory /home/documents/pdf are continuously increasing and I have to share these documents with SFTP users in real-time.

To share the documents in directory /home/documents/pdf i have created a symbolic link ln -s /home/documents/pdf /home/sftp/sftp_user1/incoming/pdf. But when FTPS user tries to access this directory he found this as a file named pdf in his home directory /incoming while I was able to access the files through the symbolic link on the SFTP server.

This has happened because, after the chroot operation, the file system has no knowledge of any data outside of the chroot directory. This lack of knowledge breaks the symlink.

Solution

Use the bind mount to remove the above issue. Bind mount is mounting a path into another path instead of mounting a device with a file system on a particular path.

[user@dbappweb.com ~]$ sudo  mount -o bind /home/documents/pdf /home/sftp/sftp_user1/incoming/pdf
[user@dbappweb.com ~]$ sudo mount |grep pdf
/home/documents/pdf on /home/sftp/sftp_user1/incoming/pdf type none (rw,bind)

Make the following entry in fstab to automount in case of a system reboot

[user@dbappweb.com ~]$ sudo cat /etc/fstab
.
.
/home/documents/pdf /home/sftp/sftp_user1/incoming/pdf none bind 0 0

Now SFTP user can access the files under directory /home/documents/pdf (on the servers) in his home directory /incoming/pdf

sftp> pwd
Remote working directory: /incoming
sftp> ls
pdf    
sftp>cd pdf
sftp> ls
file1.pdf file2.pdf ...............

Last Updated: August 09, 2020

Note: When you use the bind option of the mount command, you must be sure that the file systems are mounted in the correct order. In the following example, the /var/log directory must be mounted before executing the bind mount on the /tmp directory:

# mount --bind /var/log /tmp

Reference: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/global_file_system_2/s1-manage-mountorder

Related Posts

  • How to Setup Chroot SFTP in Linux (Allow Only SFTP, not SSH)
  • SFTP remote readdir Permission denied error
  • Connect via sftp to a specific port

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
Prev Article
Next Article
Tags:Bind Mount Linux RedHat Linux RHEL SFTP

Leave a Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2025 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com