Tuesday, July 7, 2009

Hướng dấn cài đặt máy chủ FTP cho Ubuntu

Vsftpd is the most easy ftp server to setup.

Installing vsftpd:
Code:

sudo apt-get install vsftpd

The configuration file for vsftpd is located in /etc/vsftpd.conf. The default configuration is a little bit paranoid, not so usable for file sharing. So use this configuration instead:
Code:

# Put in /etc/vsftpd.conf
# Don't forget to change samurai into your local username
listen=YES
anonymous_enable=YES
local_enable=YES
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=samurai
ftpd_banner=Welcome to blah FTP service.
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
anon_root=/home/ftp

Don't forget to backup before you use this configuration.
Code:

sudo cp /etc/vsftpd.conf /root/

Now we must make writable directory for anonymous user.
Code:

cd /home/ftp
sudo mkdir opendir
sudo chmod 777 opendir/

Ok, I explain this. In my local system, I have user named 'samurai'. With this configuration, I can log into ftp server with local user, that is 'samurai'. 'samurai' can go anywhere, create files, delete files, etc as long as he has sufficient permission.

With this configuration I can log into ftp server with anonymous user ( without username and password ). After logging in, the anonymous user jailed in /home/ftp directory ( pointed by anon_root ). I can't go outside. I can download files from /home/ftp directory but not create, delete anything from this directory. But I can write and delete files in opendir. If I write files in opendir or upload files in opendir, the files automatically belong to 'samurai' user.

To run this server:
Code:

sudo /etc/init.d/vsftpd start

To stop it:
Code:

sudo /etc/init.d/vsftpd stop

To restart it:
Code:

sudo /etc/init.d/vsftpd restart

Now it is usable for file sharing, right?!!!!

No comments: