Вы находитесь на странице: 1из 7

(/) +38 066 4846532 (tel:+38 066 4846532)

Blog
HOW TO SETUP FTP SERVER ON UBUNTU 16.04
WITH VIRTUAL USERS
Oleh Korkh - Tuesday, January 10, 2017

Sometimes you need set up an FTP for your project. In this article, I’ll show how you can setup FTP on your Ubuntu
server. First of all, install vsftpd and PAM:

$ sudo apt­get update


$ sudo apt­get install vsftpd libpam­pwdfile
Save the old configuration file. Now we can work with blank configuration.

$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak


Open the configuration and replace the file content with follows:

anonymous_enable=NO
local_enable=YES
chroot_local_user=YES
user_config_dir=/etc/vsftpd/vsftpd­virtual­user/
virtual_use_local_privs=YES
dual_log_enable=YES
connect_from_port_20=YES
listen=YES
pam_service_name=ftp
tcp_wrappers=YES
allow_writeable_chroot=YES
Restart vsftpd service:
(/)
$ sudo mkdir ­p /etc/vsftpd/vsftpd­virtual­user/
And create a blank file where we will add users with passwords a bit later:

$ sudo touch /etc/vsftpd/vsftpd­virtual­user/vsftpd_user


Copy yet another configuration file:

$ sudo cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak


And replace its content by the next one:

session optional pam_keyinit.so force revoke


auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
auth required pam_shells.so
auth include system­auth
account include system­auth
session include system­auth
session required pam_loginuid.so

Now we can create a new system user. It user will have an own separate home directory but will not allow to login
via ssh. Replace USERNAME with something you want, like ftp­myproject for example.

$ sudo useradd ­­home /home/USERNAME ­­gid nogroup ­m ­­shell /bin/false USERNAME


Then setup a password for newly created user:

$ echo USERNAME:PASSWORD|sudo chpasswd


Now we have to add the name of new user to the vsftpd_user file:

$ sudo nano /etc/vsftpd/vsftpd­virtual­user/vsftpd_user


Just add the name of the user to this file as a separate line.

Create the separate file for our user in the directory /etc/vsftpd/vsftpd­virtual­user

$ sudo nano /etc/vsftpd/vsftpd­virtual­user/USERNAME


And put the next content inside it:

local_root=/home/USERNAME
cmds_allowed=USER,PASS,SYST,FEAT,OPTS,PWD,TYPE,PASV,LIST,STOR,CWD,MKD,SIZE,MDTM,CDUP,RETR,RNFR,RN
local_umask=022
write_enable=YES

If you want to give a permission for deleting files to your new user than just add DELE to the argument
cmds_allowed .

That’s all. Now you can use your FTP client to connect with corresponding user and password. The root of your FTP
is . You also can use mount command to share any directory to your FTP root. Like that:

(/)
$ sudo mount ­­bind SOURCE /home/USERNAME/DESTINATION

Oleh Korkh (https://plus.google.com/+OlehKorkh?rel=author)

Share
Share Like 5 Tweet

1 Login
(/)
Share Sort by Best

Start the discussion…

LOG IN WITH OR SIGN UP WITH DISQUS ?

Name

THE7BITS | PYTHON-DJANGO START-UP DEVELOPMENT

How To Develop Custom Widget in Django Objects clustering and grouping with Django,
• PostGIS and Google Maps
— awesome, simple and useful •
— awesome, more write-ups
like this would be nice

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd Disqus' Privacy PolicyPrivacy PolicyPrivacy

Recent Posts

How we were looking for competitors for the start-up Crane-Locator (/blog/how-we-were-looking-for-competitors-
for-the-start-up-crane-locator)

Django, Flask, and Redis Tutorial: Web Application Session Management Between Python Frameworks
(/blog/django-flask-and-redis-tutorial-web-application-session-management-between-python-frameworks)

How to Integrate OAuth 2 Into Your Django/DRF Back-end Without Going Insane (/blog/how-to-integrate-oauth-2-
into-your-django-drf-back-end-without-going-insane)

Crane-Locator Included the Top 20 Startups for Startupbootcamp Accelerator in Amsterdam (/blog/crane-locator-
included-the-top-20-startups-for-startupbootcamp-accelerator-in-amsterdam)

Free HTTPS for Django project on Heroku (/blog/free-https-for-django-project-on-heroku)

Toptal's List Of Top Free Programming Books (/blog/toptals-list-of-top-free-programming-books)

Installing Django on IIS: A Step-by-Step Tutorial (/blog/installing-django-on-iis-a-step-by-step-tutorial)

How to setup FTP server on Ubuntu 16.04 with virtual users (/blog/how-to-setup-ftp-server-on-ubuntu-16-04-with-
virtual-users)
-the-

(/) (/blog/under-the-hood-of-a-software-development-process)

Tags

accelerator (1) (/blog/tag/accelerator/)

bcappstore (2) (/blog/tag/bcappstore/)

case-study (1) (/blog/tag/case-study/)

competitor analysis (1) (/blog/tag/competitor_analysis/)

competitors indicators (1) (/blog/tag/competitors_indicators/)

competitors monitoring (1) (/blog/tag/competitors_monitoring/)

competitors research (1) (/blog/tag/competitors_research/)

development (5) (/blog/tag/development/)

django (5) (/blog/tag/django/)

featured (1) (/blog/tag/featured/)

forms (1) (/blog/tag/forms/)

heroku (1) (/blog/tag/heroku/)

IIS (1) (/blog/tag/IIS/)

lean development (2) (/blog/tag/lean_development/)

market research (1) (/blog/tag/market_research/)

marketplace development (1) (/blog/tag/marketplace_development/)

online product launching (1) (/blog/tag/online_product_launching/)

products (3) (/blog/tag/products/)

python (4) (/blog/tag/python/)

site (1) (/blog/tag/site/)

startup (2) (/blog/tag/startup/)


(1) (/blog/tag/startup_development/)

(/)
ubuntu (1) (/blog/tag/ubuntu/)

zendesk (2) (/blog/tag/zendesk/)

Archive

March 2018 (1) (/blog/calendar/2018/3/)

GET A FREE QUOTE

Your Name

Your email address

REQUEST QUOTE

You will receive quarterly promotions and news. Unsubscribe with one click.

DROP US A LINE
(/) ADDRESS

Gendt, Netherlands
Willem Alexanderstraat 19, 6691 EE
Poltava, Ukraine
Yevropeiska St, 6b, office 11, 36000
(/contact#map-canvas)

PHONES

+31 639 110346 (NL) (tel:+31 626 852410)


+38 066 4846532 (UA) (tel:+38 066 4846532)

EMAIL

inbox@the7bits.com (mailto:inbox@the7bits.com)


   
(https://www.youtube.com/channel/UCGl-
(https://www.facebook.com/pages/The7bits/1447644852212022)
(https://www.linkedin.com/company/the7bits)
(https://twitter.com/the7bits_yes)
oN1mkPxLDyXCeqx8e4A)
(https://plus.google.com/+The7bits/posts/p/pub)

The7bits © 2015   | Privacy Policy (/website/privacy) | Sign In (/accounts/sign-in)

Вам также может понравиться