If you've installed an FTP daemon on your Ubuntu server, you'll have probably set it up so that users are rooted to their own FTP directory on the server. But what if you'd like an FTP user to have access to other directories on the server? A symbolic link sounds like it would work, but I'm afraid it won't. You'll have to mount the folder you're interested in to the user's FTP folder.

Assume that we've got a user called "russell" and you've set up your FTP so that he has his own FTP folder at /var/ftp/russell/. Also assume that you want to give him access to the /var/www/ folder so that he can update the web sites on your server.

We're going to mount a folder into a subdirectory in his FTP directory, so create a suitable directory for that:


$ cd /var/ftp/russell$ mkdir www

Now we mount the /var/www directory into /var/ftp/russell/www/:


$ mount --bind /var/www /var/ftp/russell/www

Making It Persist

Unfortunately this command will only last until the next reboot, so you're going to have to add it to a startup script. First lets change to our home directory so we can create the script:


$ cd ~

Then lets create a script called "mountftp":


$ nano mountftp

Enter the following into your script (obviously replacing any paths with ones on your own system):


#! /bin/shmount --bind /var/www /var/ftp/russell/www

Now save the file and exit Nano. To make the script execute at boot time, we will have to copy it to the /etc/init.d folder and let ubuntu know we want it executed.

So copy the script to /etc/init.d and give it execute permissions:


$ cp mountftp /etc/init.d/$ chmod +x /etc/init.d/mountftp

Next we need to tell Ubuntu about the script:


$ cd /etc/init.d$ update-rc.d mountftp defaults

You should see output similar to this:


Adding system startup for /etc/init.d/mountftp ...   /etc/rc0.d/K20mountftp -> ../init.d/mountftp   /etc/rc1.d/K20mountftp -> ../init.d/mountftp   /etc/rc6.d/K20mountftp -> ../init.d/mountftp   /etc/rc2.d/S20mountftp -> ../init.d/mountftp   /etc/rc3.d/S20mountftp -> ../init.d/mountftp   /etc/rc4.d/S20mountftp -> ../init.d/mountftp   /etc/rc5.d/S20mountftp -> ../init.d/mountftp

And that's it, your ftp directories will now be restored on every reboot.

Comments are closed

I am a software developer / architect currently interested in combining .NET technologies with open-source operating systems. 

I am a member of the open-source BlogEngine.NET development team and focus mainly on ensuring Mono compatibility for the project.

twitter

BlogEngine.NET


At StayUnlimited Cape Town accommodation we help you choose from and book guest houses, self catering apartments, bed & breakfasts, luxury villas and hotel accommodation.