Symlinks and Chroot()
How to add more directory's to a chrooted / jailed account.
So you have an ftp server running, you allow access to bob.
He has been locked down (chroot'ed) to a certain directory and not allowed system wide access to any where else.
All good.
But what if you want him to access another directory outside he's chrooted directory!?!?!
First thing on your mind is lets make a symlink to the files/directory like we do everyday. The ftp server wont read the same
A quick run down example:
Bob is chooted down to /home/bob/, he cant change to any other directory besides whats contained in /home/bob/ for him to access by ftp.
Bob has asked for access to /home/sandy/pictures/porn/ (just a good example to keep you awake) making a symlink:
ln -s /home/bob/porn /home/sandy/pictures/porn"
will work but when bob is trying to access the files by ftp, the ftp server would just deny him access or flick him back to his home root.
Why would the ftp server do that?
When you chrooted bob ftp account, your making that directory you set his root;
To bob, hes ftp root location is /
To the real file system, hes location is /home/bob/
So if we linked a real file system directory like /home/sandy/pictures/porn to bobs chrooted location /, the ftp server will read it as /home/bob/home/sandy/pictures/porn which it exist in the filesystem but doesnt exist in bob's ftp chrooted directory.
Hope you get what I mean.
Using Mount to overcome the problem!
In Windows, its X: X being a letter
In Linux, you can mount a CD Rom, Floppy Disk, Partition, Additional Hard Drive or even a Directory to any location in the current file system of your choice.
e.g Your CD Drive = /home/john/drives/cdrom1 Your Floppy Disk = /media/floppy
NOTE: Please read this page as a reference before continuing on. As it may help, some references might relate to Ubuntu Linux.
| house cover buy to let mortgage online comparison visit now |
Anyways to continue on with Mount
By using mount, we can get the ftp to allow bob access to the other locations we want.
Lets make a directory where we can mount sandys porn to:
mkdir sandyporn
Now lets mount sandys directory into bobs new directory sandyporn.
sudo mount --bind /home/sandy/pictures/porn /home/bob/sandyporn
Now bob can ftp into hes chrooted account while being able to access sandy's porn directory too!
If you want to make it permanent even after a computer reboot,You will need to add a line to your fstab file.
sudo nano /etc/fstab
On the last line, add:
/home/sandy/pictures/porn /home/bob/sandyporn none defaults,bind 0 0
Hope that helps you, many people always run into this problem. This can also be used for ssh chrooted / jailed accounts.
Edit----Update---
Been helping quite a few via email, some notes:
-When you mount from a existing file system already, permissions will be carryed other. So look at your Owner User Other permissions of the files your mounting.
-If you get unknown file system in '/etc/fstab', try "auto bind 0 0" instead of "none defaults, bind 0 0"
Comments
500 Failed to change directory
Hmm
No, I'm just using Ubuntu
Ok, now it's working fine.
Good one
Post new comment