How to Install vsftpd on Ubuntu

Build it and learn to secure your system/server.


How to Install vsftpd on Ubuntu

Postby tanmay.01 » Mon Jul 01, 2013 5:48 pm

This tutorial focuses on how to setup vsftpd server on your linux based VPS or a dedicated server. The vsftpd stands for “Very Secure FTP Daemon”. It is not just secure as the name suggests but also delivers excellent performance by consuming less memory. The tutorial also teaches you how to configure by adding ftp users and locking the directory to individual users.

Code: Select all
sudo apt-get install vsftpd


Now that you’ve installed vsftpd, follow this procedure to configure it.

Code: Select all
sudo service vsftpd stop


Now edit the config file

Code: Select all
nano /etc/vsftpd.conf


We don’t want anonymous login:

Code: Select all
anonymous_enable=NO


Enable local users:

Code: Select all
local_enable=YES


The ftpuser should be able to write data:

Code: Select all
write_enable=YES


Chroot everyone:

Code: Select all
chroot_local_user=YES


set umask to 022 to make sure that all the files (644) and folders (755) you upload get the proper permissions.

Code: Select all
local_umask=022


Add this too, as linux has passive ftp and you want to access it outside the local network.

Code: Select all
# My Config
pasv_enable=YES
pasv_addr_resolve=YES
#user ddns address
pasv_address=ueftptest.no-ip.org
#choose and range you like
pasv_min_port=4242
pasv_max_port=4252

# the list of users to give access
userlist_file=/etc/vsftpd.userlist

# this list is on
userlist_enable=YES
# It is not a list of users to deny ftp access
userlist_deny=NO

#one more
allow_writeable_chroot=YES
seccomp_sandbox=NO


Now that basic configuration is complete, now let us begin with locking / securing a directory to user.

Code: Select all
sudo useradd -d /var/www/path/to/your/dir -s /usr/sbin/nologin ftpuser


Setup a password for the user:

Code: Select all
sudo passwd ftpuser


In order to enable the ftpuser read and write the data in your home dir, change the permission and take ownership:

Code: Select all
sudo chown -R ftpuser /var/www/path/to/your/dir
sudo chmod 775 /var/www/path/to/your/dir


Create userlist file and add the user:

Code: Select all
sudo nano /etc/vsftpd.userlist


and add the user:

Code: Select all
ftpuser


After completing all these procedures it is almost ready to use it, give it a try but you will get a 500 OOPS permission denied error. To fix it you need to add a nologin to the shell set.

Code: Select all
sudo nano /etc/shells


Add this line at the end:

Code: Select all
/usr/sbin/nologin


Now create a usergroup and add the ftpuser to it:

Code: Select all
sudo addgroup ftpusers
sudo usermod -Gftpusers ftpuser


One final thing, to access from outside network and avoid : 530 login error do this

Code: Select all
sudo nano /etc/pam.d/vsftpd


Comment the second line below :

Code: Select all
# Standard behaviour for ftpd(8).
#auth   required        pam_listfile.so item=user sense=deny file=/etc/ftpusers$


Now start the vsftpd:

Code: Select all
service vsftpd start


That’s it. Now you have a secure installation of vsftpd on your server.

[ Only complete solution on Ultimate Edition Forum and this works because i tried it myself and put together the solutions for many errors. ]

Local Login :
localftp.png


Web Login :
webftplogin.png
HP ENVY 15
•3rd generation Intel(R) Core(TheeMahn) i5-3210M Processor (2.5 GHz with Turbo Boost up to 3.1 GHz)
• 1GB Radeon(TheeMahn) HD 7750M GDDR5 Graphics [HDMI]
• 6GB 1600DDR3 System Memory (2 Dimm)
• 750GB 7200 rpm Hard Drive
• Intel 2x2 802.11a/b/g/n WLAN + Bluetooth(R)
• Full-size Radiance backlit keyboard.

Image
User avatar
tanmay.01
Moderator
 
Posts: 264
Joined: Wed Dec 07, 2011 5:03 pm
Location: India
Age: 23
Operating System: Other Linux



Re: How to install vsftpd on Ubuntu ?

Postby ryanvade » Mon Jul 01, 2013 5:51 pm

How do you incorporate services like no-ip into this?
Image

Laptop: HP dv6t-7000 CTO Desktop: Compaq Presario SR21632wm
i5 2450m Pentium D 960 @ 4 GHz
6 GB ram 2 GB ram
Intel HD 3000 Graphics / Nvidia GT 630M Nvidia GT 520 @ 820 MHz
Diamond II-B 3.10-rc4/Windows 7 Home Premium KDE | Windows 7 Starter/Arch Linux

Paid supporter of the Linux Foundation
User avatar
ryanvade
Moderator
 
Posts: 524
Joined: Sat Apr 28, 2012 2:54 pm
Operating System: Other Linux



Re: How to install vsftpd on Ubuntu ?

Postby tanmay.01 » Mon Jul 01, 2013 5:53 pm

No-ip into ftp or no-ip as ddns..?
HP ENVY 15
•3rd generation Intel(R) Core(TheeMahn) i5-3210M Processor (2.5 GHz with Turbo Boost up to 3.1 GHz)
• 1GB Radeon(TheeMahn) HD 7750M GDDR5 Graphics [HDMI]
• 6GB 1600DDR3 System Memory (2 Dimm)
• 750GB 7200 rpm Hard Drive
• Intel 2x2 802.11a/b/g/n WLAN + Bluetooth(R)
• Full-size Radiance backlit keyboard.

Image
User avatar
tanmay.01
Moderator
 
Posts: 264
Joined: Wed Dec 07, 2011 5:03 pm
Location: India
Age: 23
Operating System: Other Linux



Re: How to install vsftpd on Ubuntu ?

Postby ryanvade » Mon Jul 01, 2013 5:54 pm

ftp
Image

Laptop: HP dv6t-7000 CTO Desktop: Compaq Presario SR21632wm
i5 2450m Pentium D 960 @ 4 GHz
6 GB ram 2 GB ram
Intel HD 3000 Graphics / Nvidia GT 630M Nvidia GT 520 @ 820 MHz
Diamond II-B 3.10-rc4/Windows 7 Home Premium KDE | Windows 7 Starter/Arch Linux

Paid supporter of the Linux Foundation
User avatar
ryanvade
Moderator
 
Posts: 524
Joined: Sat Apr 28, 2012 2:54 pm
Operating System: Other Linux



Re: How to install vsftpd on Ubuntu ?

Postby tanmay.01 » Mon Jul 01, 2013 5:56 pm

Like this

Code: Select all
# My Config
pasv_enable=YES
pasv_addr_resolve=YES
#user ddns address
pasv_address=ueftptest.no-ip.org


Dont use ftp unless you really need it, else use scp.
HP ENVY 15
•3rd generation Intel(R) Core(TheeMahn) i5-3210M Processor (2.5 GHz with Turbo Boost up to 3.1 GHz)
• 1GB Radeon(TheeMahn) HD 7750M GDDR5 Graphics [HDMI]
• 6GB 1600DDR3 System Memory (2 Dimm)
• 750GB 7200 rpm Hard Drive
• Intel 2x2 802.11a/b/g/n WLAN + Bluetooth(R)
• Full-size Radiance backlit keyboard.

Image
User avatar
tanmay.01
Moderator
 
Posts: 264
Joined: Wed Dec 07, 2011 5:03 pm
Location: India
Age: 23
Operating System: Other Linux



Re: How to install vsftpd on Ubuntu ?

Postby ryanvade » Mon Jul 01, 2013 6:03 pm

Code: Select all
pasv_address=ueftptest.no-ip.org

That was what I was looking for. Thanks.

I think I will try ssh first. Good tutorial for that?
Image

Laptop: HP dv6t-7000 CTO Desktop: Compaq Presario SR21632wm
i5 2450m Pentium D 960 @ 4 GHz
6 GB ram 2 GB ram
Intel HD 3000 Graphics / Nvidia GT 630M Nvidia GT 520 @ 820 MHz
Diamond II-B 3.10-rc4/Windows 7 Home Premium KDE | Windows 7 Starter/Arch Linux

Paid supporter of the Linux Foundation
User avatar
ryanvade
Moderator
 
Posts: 524
Joined: Sat Apr 28, 2012 2:54 pm
Operating System: Other Linux



Re: How to install vsftpd on Ubuntu ?

Postby tanmay.01 » Mon Jul 01, 2013 6:05 pm

Tomorow or day after , because i too want to know about ssh in detail, basics about ssh can get you in trouble of exposing keys to the internet...! ;)

You need to resolve address before that. The line above .
HP ENVY 15
•3rd generation Intel(R) Core(TheeMahn) i5-3210M Processor (2.5 GHz with Turbo Boost up to 3.1 GHz)
• 1GB Radeon(TheeMahn) HD 7750M GDDR5 Graphics [HDMI]
• 6GB 1600DDR3 System Memory (2 Dimm)
• 750GB 7200 rpm Hard Drive
• Intel 2x2 802.11a/b/g/n WLAN + Bluetooth(R)
• Full-size Radiance backlit keyboard.

Image
User avatar
tanmay.01
Moderator
 
Posts: 264
Joined: Wed Dec 07, 2011 5:03 pm
Location: India
Age: 23
Operating System: Other Linux


Return to Server and Security

Who is online

Users browsing this forum: No registered users and 2 guests