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!

5 comments

  • What about setting up SFTP and generating private/public keys for it?

  • Joseph

    thegeekstuff.com@Omar SFTP uses the OpenSSH server.

    sudo apt-get install openssh-server openssh-client

    Then in the client you log in like you normally would but using the port 22. (Unless you change it to something else in the openssh config file) and you can add users with useradd. As for private/public keys, that doesn’t exactly relate to SFTP but you can follow this guide:

    http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/

    All that does is allow you to log into a ssh “secure shell” session without having to enter your password.

  • this won’t work because FTPS (vsftpd supports this) and SFTP (vsftpd doesn’t) are completely different protocols. There’s a lot of confusion on the net about this. I don’t think vsftpd can be used on port 22 at an SFTP client

  • Hi erik. Thanks for the posting. I have worked with FTP and it works. I am not sure about SFTP I will do some more research on it and get back to you. Thanks

  • nuno

    Hi eric,

    im having problems configuring vsftpd to support my cisco routers infrastructure, the problem is that cisco routers/switches do not support the authentication request from vsftpd, so i would need to configure vsftpd to allow rw access but not asking for any credentials, can you please let me know how can i do this?

    best regards,

    NL

Leave a Reply

Your email address will not be published. Required fields are marked *