Tuesday, November 30, 2010

Linux Tutorial: 3 Minute FTP server setup on Ubuntu


I like all my websites’ directories under /var/www, for instance http://www.somewebsite.com would be hosted under /var/www/www.somewebsite.com. This tutorial will show you what I had to do to get jailed FTP working under Ubuntu 8.10 using vsftpd with this setup.

Note: I disabled sudo completely, so adapt to your needs if you still have it enabled.

First off we need to install vsftpd:
apt-get install vsftpd

Then, edit the config file to turn off anonymous users:
joe /etc/vsftpd.conf

Change:
anonymous_enable=YES to
anonymous_enable=NO

Remove the hash in front of
write_enable=YES

Remove the hash in front of
local_enable=YES

Remove the hash in front of
chroot_local_user=YES

Remove the hash in front of
ls_recurse_enable=YES

and save by pressing Ctrl-k followed by x

Next, add the user, for these purposes we are going to use a user with name ‘myfirstweb’ and website located @ /var/www/www.myfirstweb.com:
useradd myfirstweb -d /var/www/www.myfirstweb.com -s /bin/false

Add the fake shell to /etc/shells:
joe /etc/shells
add
/bin/false

on a new line and press Ctrl-k followed by x to save.

restart the FTP daemon:
/etc/init.d/vsftpd restart

And you are done. This created the account and the user should be able to log in and end up in the correct directory.

If you are still unable to create files, run a chown and chmod on the web directory to make sure it is owned by the FTP user and it has write rights as well.

No comments:

Post a Comment