How to use ftp on Ubuntu (vsftp installation)

When you upload a website, ordinarily you use sftp, but the need to create a restricted user appears, so note that way to make it in ubuntu.

Now as an example, in order to use ftp, we will create a new user called “iwaking”.

Add user.

# useradd iwaking

Setup password.

# passwd iwaking

Set up to refuse users login via ssh, allow only ftp user’s access this time.

# vim /etc/ssh/sshd_config
DenyUsers iwaking

And the ftp server is famous for vsftp, so you will install it.

# yum install vsftpd

Next, setting vsftpd.

# vi /etc/vsftpd/vsftpd.conf

I will describe only the points that have changed.

#Turn off anonymous user
anonymous_enable=NO

#Allow ASCII mode when uploading and downloading
ascii_upload_enable=YES
ascii_download_enable=YES

#Turn on chroot_list, and restrict user scope
chroot_list_enable=YES
chroot_local_user=YES
chroot_list_file=/etc/vsftpd/chroot_list

#Specify a valid user account in the user_list file
userlist_enable=YES
userlist_deny=NO

Next, edit “user_list” file. This is the user permission list.
In this scenario, a user who is given permission is “iwaking”.

# vi /etc/vsftpd/user_list
#root
#bin
#daemon
#adm
#lp
#sync
#shutdown
#halt
#mail
#news
#uucp
#operator
#games
#nobody
iwaking

There is “ftpusers” file which is a rejection list.
In this scenario, it is OK if “iwaking” is not in the list. #

# vi /etc/vsftpd/ftpusers
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

There is “chroot_list” file which is rejection list for chroot.
I do not edit this file as chroot will be done.

start vsftpd

# /etc/init.d/vsftpd restart

Configure them to run with starting up.

# chkconfig --level 345 vsftpd on

Release port 20 and 21, if you are running a firewall.

Try to login from local machine as

# chkconfig --level 345 vsftpd on
# ftp host_name
Name : iwaking
331 Please specify the password.
Password:

If login is successful, then it is done.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.