Setting up FTP or SFTP server using vsftpd on ubuntu

Posted by Dhaval Parikh on Nov 5, 2009 |
Subscribe

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..

Tags: , , , ,

5 Comments

Omar
Nov 15, 2009 at 4:43 am

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


 
Joseph
Oct 1, 2010 at 3:17 am

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.


 
erik
Oct 24, 2011 at 9:52 pm

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


 
Dhaval Parikh
Oct 24, 2011 at 10:01 pm

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


 

[...] http://blog.dhavalparikh.co.in/2009/11/setting-up-ftp-or-sftp-server-using-vsftpd-on-ubuntu/ Share this:TwitterFacebookLike this:Be?enBe the first to like this [...]


 

Reply

 

Copyright © 2012 Dhaval Parikh All rights reserved. Theme by Laptop Geek.