Setting up FTP or SFTP server using vsftpd on ubuntu

Recently I was given a task to configure FTP server so that the user can upload files through FTP. I found VSFTPD really a good solution for it. Its very simple to configure Here are the steps

1) Install vsftpd using the following command

sudo apt-get install vsftpd
2) On doing so it will get installed in /etc path by default. To confirm the same go to /etc/vsftpd.conf using

sudo nano /etc/vsftpd.conf

Now if you want to allow local users to login find local_enable=YES  and uncomment it

To disable anonymous ftp change anonymous_enable=YES to anonymous_enable=NO

Uncommenting the line (write_enable=YES) will let ftp users upload content to the server. (Thats what I wanted to do)

Thats all its done. Restart the server using

sudo /etc/init.d/vsftpd restart

This is how you will be able to allow ftp login.

But if u have many sites hosted on a server and you want to allow to access only one particular site to a certain user you need to do the following

1) create groups for specific sites using

groupadd site1
chgrp -R site1 /var/www/site1

2) Add user to that group

useradd -G site1 username

3) Give permission to a particular group

chmod -R  g+w /var/www/site1/*

I think thats all. You should be able to access your server using ftp and even upload content on it.

Oh yes one more thing was I wanted the user to go directly to the folder where i wanted him to upload the file. So for that you need to change the root path/home path. For this u need to open passwd file in /etc using

nano /etc/passwd

Looks for the ftp access and the username You will find the current path. In most cases it will be /home change that to your preferred one.

Hmm Thats it..

Be Sociable, Share!