Article: vsftpd on Suse Linux pro »
FERDY CHRISTANT - AUG 23, 2005 (05:49:57 PM)
This week my holiday started, for 3 weeks I will not have to work. Next week I will have my actual holiday in Ireland with 3 friends, the other two weeks I'll mostly spend relaxing and catching up with things.
Today's follow-up activity is on setting up a vsftpd (Very Secure FTP Daemon) server on my new Suse installation. The Suse website claims this is a 5 minute job, because the package comes installed with Suse 9.3. All I was supposed to do is edit one config file.
Not for me. In the end I spend an entire day getting it to work exactly the way I want it to. Partly because I'm a Linux n00b, partly because the specifics of setting up my installation were not in the basic instructions from Novell. After my 19th nervous breakdown, I have what I want. Looking back at the process, it is still not intuitive to me. That's why I'll list my steps in this mini article, so I can remember it next time I have to do this. Maybe it is of use to you as well.
Goal
vsftpd promises security and performance, and is well recommended by the Linux community. Not wishing to argue with that, I decided this would be the package I need. The setup I want is simple:
- The FTP server must be accessible from both my Linux and Windows machine
- Anonymous users should not have access at all
- One or more users get full access to the FTP root directory, these users will be managed using local Linux accounts
This may seem like a very straight-forward installation, but it's not. vsftpd has a number of example configurations, located in the usr/share/doc/packages/vsftpd/example directory, but my setup is not listed in there.
Installation
vsftpd runs on any Linux kernel, yet the installation instructions may differ per distribution. For Suse, I simply opened Yast, choose the "Add software option", and selected the vsftpd package to install. Next, I had to insert CD 4 and go ahead with the installation. Look up the instructions for your distribution. The rest of this article should work similar irrespective of your distribution.
Security
I wanted to create a separate user for ftp administration access, so I did. This user will have full access to it's own home directory, which will be the shared FTP root directory. Log in as root user, and execute the following commands in the console:
# create the FTP root dir
mkdir /srv/ftp
# create a FTP user group
groupadd ftp-users
# make the new FTP root dir accessible for ftp-users
chmod 750 /srv/ftp
chown root:ftp-users /srv/ftp
# add new ftpadmin user to group and set its home dir to the FTP root
useradd -g ftp-users -d /srv/ftp ftpadmin
# set password of new ftpadmin user
passwd ftpadmin
# give read/write access to the FTP root dir
chmod 770 /srv/ftp
Configuration
This is the most important step. It consists of creating a few configuration files. The most important file is vsftpd.conf, which you should create in the /etc directory. Below is my listing of this file, included with comments:
#disallow anonymous ftp access
anonymous_enable=NO
# allow local users to log in
local_enable=YES
# allow FTP write commands
write_enable=YES
# umask for local users, (022 is used by most other ftpd's)
local_umask=022
# make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
# disable chmod, default is YES
chmod_enable=NO
# login banner string
ftpd_banner=Welcome to the s3maphor3 FTP service
# enable/specifiy list of local users to chroot() to their home directory.
# if chroot_local_user is YES, then this list becomes a list of users to NOT chroot().
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
# authentication service
pam_service_name=vsftpd
# disable user list
userlist_enable=NO
# enable for standalone mode
listen=YES
We have specified to "chroot" users. This means that authenticated FTP users will be directed to the home dir specified in the user account. Since we have this set this up for the ftpadmin account, this is what we want. The list of users to chroot is maintained in a file called vsftp.chroot_list in the /etc directory. Mine looks like this:
ftpadmin
Finally, a third file is needed to complete the configuration. We want the FTP server to start when the system is started, and to be stopped when the system is shutdown. To realize this, we need to create a script file named vsftpd in the /etc/init.d diectory:
#!/bin/sh
case "$1" in
start)
echo "Starting vsftpd ..."
/usr/sbin/vsftpd &
;;
stop)
echo "Stopping vsftpd ..."
killall vsftpd
;;
*)
echo "Usage: 'basename $0' {start|stop}" >&2
exit 64
;;
esac
exit 0
This completes the configuration of vsftpd. Let's test it.
Local test
Before trying to access the FTP server from a remote machine, it is wise to do a local test, to see if your configuration is working without the worries of a firewall. First make sure the vsftpd service is started. It should run automatically when you have rebooted, but you can also kick it manually. Since I run vsftp in stand-alone mode (outside of the xinet network service), the command to start it would be:
/usr/sbin/vsftpd &
The command to stop it is:
killall vsftpd
Now that the service is started, let's do a local test. Here's my successfull FTP session, based on the configuration above:
linux:~ # ftp localhost
Trying 127.0.0.1...
Connected to localhost.
220 Welcome to the s3maphor3 FTP service
Name (localhost:root): ftpadmin
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
If anything goes wrong while starting the service or doing the local test, remember the error number and do a google :)
Firewall settings
Many Linux distributions by default have their firewall enabled. This is a good thing. I found out that Suse does not allow FTP traffic from a remote machine. The way to configure it to allow FTP traffic may differ per distribution. I have used the Yast control panel, security section, firewall, advanced dialog and added port 21 (FTP control) and port 20 (FTP data) to the TCP ports.
Remote test
The last step in the process is testing remote FTP access. For this purpose I have simply used a command prompt as FTP client on my Windows machine. Here's my successfull remote FTP session output:
C:\>ftp 192.168.0.115
Connected to 192.168.0.115.
220 Welcome to the s3maphor3 FTP service
User (192.168.0.115:(none)): ftpadmin
331 Please specify the password.
Password:
230 Login successful.
Where 192.168.0.115 is the IP address of your FTP server. You can check the address in Linux using the ifconfig command (look for inet addr in the output)
This concludes the instructions on how to setup vsftpd for secure users. I hope I'm helping anyone with this, if not, it sure is a good reminder for myself :)


Comments: 61
Reviews: 28
Average rating:
Highest rating: 5
Lowest rating: 3
COMMENT: AQUILO
AUG 25, 22:56:40
COMMENT: BCC
SEP 3, 18:42:23
COMMENT: BCC
SEP 4, 13:23:35
COMMENT: ROK
SEP 20, 11:50:19
But I found one error:
The list of users to chroot is maintained in a file called vsftp.chroot in the /etc directory.
The file name must be: vsftp.chroot_list
Anyway now its working «
COMMENT: FERDY
SEP 20, 19:09:40
Rok, you are right, sorry for that. I corrected the mistake. «
COMMENT: PSYCHOCODE

SEP 21, 13:11:38
COMMENT: JOSEF
SEP 26, 13:54:41
bet you know but you should NEVER login as ftpadmin remotely. All ftp transfers are in plaintext (even your password) so sftp or ssh is way better. «
COMMENT: GWB

JAN 30, 05:33:49 PM
COMMENT: FERDY
JAN 31, 06:31:31 PM
Hmmm, did you open up both port 21 and 20? I think both are needed. Give it a try.... «
COMMENT: LINUX NEWBIE
FEB 9, 06:41:42 PM
:) «
COMMENT: DUTCHFROG
FEB 15, 04:39:43 PM
Then, stop and restart the Firewall. Control that the settings have been changed (just look again into the "advance" settings, if they are shown.
I'm a newbie too, but after I entered the Protocols I could connect from the remote machines without problem. And, damned, it's fast! «
COMMENT: UGE
FEB 16, 08:04:36 AM
TSM-Linux:~ # ftp localhost
Trying 127.0.0.1...
Connected to localhost.
220 Welcome to USI3 Area Tasikmalaya FTP service
Name (localhost:root): ftpadmin
331 Please specify the password.
Password:
500 OOPS: could not open chroot() list file:/etc/vsftpd.chroot_list
ftp: Login failed.
ftp>
anyone know why?
and when i try from win xp, its say :
Connection closed by remote host
i turn of the firewall when i did this try. «
COMMENT: FRANCESCO
FEB 17, 14.10.13
chroot_list_file=/etc/vsftpd.chroot_list (note the letter "d" after vsftp)
After wrote "The list of users to chroot is maintained in a file called vsftp.chroot_list in the /etc directory..." (note there is no letter "d")
As you can see the the file name isn't the same chek in your vsftpd.conf at the parameter [chroot_list_file=] then correct your vsftpd.chroot_list file name!
The connection problem is probably caused by your firewall settings... read the article! «
COMMENT: SHAWN BISHOP

MAR 9, 08:18:52 AM
"I would like if possible a tutorial also for adding anonymous users and admin user, both having the same path, only the admin having the privileges to erase/write new files, whilst anonymous only having the privilege to read"
Has anybody got this working yet,I have prevented deletion of files from all directories,but I want an admin/root user that can delete these files when they login
Cheers «
COMMENT: HERTA

MAR 10, 07:15:26
COMMENT: THOMAS

MAR 13, 09:09:06 PM
One comment, even if it may be obvious for everbody - except me first time. You have to create the user ftpadmin or type in a user name that is exists in your system. «
COMMENT: CERPHER
MAR 17, 12:36:42 AM
Thanks to Shawn B. for adding the file name in vsftpd.conf
I tested ftp lcoalhost and it worked. I went to a XP pc to try to ftp but kept getting time out. I thought about the firewall, port 21 and 20.
Followed the steps to use YAST but could not find how to add port 21 and 20. I did see 4 section tcp, udp, rpc, & ip.
Do I put 21 in the tcp and 20 in ip? Should I put 20, 21 in tcp or put 20 and 21 in tcp?
One last thing which I had problems is the SSL.
vsftpd.conf
ssl_enable=YES did not work with ftp localhost
ssl_enable=NO did work with ftp localhost
I believe I would need ssl enabled but I get an ssl compile error. «
COMMENT: CERPHER
MAR 17, 12:38:24 AM
COMMENT: CERPHER
MAR 18, 05:06:02 AM
Every thing is working, Thanks again
Correction is was FRANCESCO not SHAWN
about the vsftp being vsftpd in the vsftpd.chroot_list «
COMMENT: BUBO

MAR 18, 08:18:54 PM
Just a small problem though, don't know if you can help?
When I run /usr/sbin/vsftpd & I get the following error:
# /usr/sbin/vsftpd &
[1] 7973
# 500 OOPS: missing value in config file for:
I have checked the syntax several times now and can't see what wrong. Ani idea's?
Bubo «
COMMENT: CERPHER
MAR 23, 09:35:49 PM
I also got the error when I had the vsftp.conf instead of vsftpd.conf file
I also got the error when I did not have the vsftpd.chroot_list
got the error when I did not do the chmod setting user rights
I just set the permission to read for the group
Remember if you do all the steps above it will work find
Just set permission for the group or others to read
e-mail me if you need more help «
COMMENT: NAME
MAR 28, 02:04:21 PM
COMMENT: SIDNEY

APR 5, 06:53:58
I had my ftp server working, could connect from machines on my network and from remote machines from a dos client.
but when I entered ftp://myserver.myddnsserver I got.
"the operation timed out"
I searched and searched for the answer.
Thanks Dutchfrog for "In the protocol field add [FTP TCP IP]" «
COMMENT: JOHN

APR 23, 11:43:19 PM
COMMENT: LENNY
MAY 3, 03:51:56 AM
COMMENT: RED
MAY 26, 04:25:00 PM
thank you very much for this tutorial. I spent all day yesterday following a different setup tut, only to come to dead stop when the setup didnt work. Your setup and instructions is exactly what i needed, and it worked without a hitch. Thanks Again !! «
COMMENT: TONY
JUL 27, 01:16:15 PM
I got stuck after I entered ftpd_banner=Welcome .... I am running Suse 10.1. I cannot get out of the command! Anybode any suggestions «
COMMENT: BOB
AUG 13, 01:59:01 PM
Another clear walkthrough that has stopped me ditching linux in frustration! Thanks «
COMMENT: WEIS
AUG 30, 10:15:42
COMMENT: LIKEWHOA

SEP 30, 11:21:12 PM
# 500 OOPS: missing value in config file for:
Error, what you need to do, is clear all comments of the vsftpd.conf file and only use your settings, this worked for me. this could be a parse error with this version, who knows.. but for reference here is my current settings that work.
ftpd_banner=Welcome to my 1337 FTP service.
anonymous_enable=NO
local_enable=YES
local_umask=022
write_enable=YES
dirmessage_enable=YES
connect_from_port_20=YES
data_connection_timeout=120
nopriv_user=nobody
xferlog_enable=YES
xferlog_file=/var/log/vsftpd/vsftpd.log
xferlog_std_format=YES
nopriv_user=nobody
chroot_list_enable=YES
chroot_local_user=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
ascii_upload_enable=YES
ascii_download_enable=YES
listen=YES
pasv_enable=YES
pasv_min_port=7700
pasv_max_port=7710
pasv_address=1.2.3.4
pasv_promiscuous=YES
port_promiscuous=YES
ssl_enable=YES
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
ssl_sslv3=YES
ssl_sslv2=YES
ssl_tlsv1=YES
force_local_logins_ssl=No
force_local_data_ssl=No
hope this helps others, as this took me 30mins to figure out, lol
«
COMMENT: VAIBHAV VERMA
OCT 2, 04:23:09 AM
COMMENT: VAIBHAV VERMA
OCT 2, 04:24:12 AM
COMMENT: AARON

OCT 9, 02:47:34 AM
COMMENT: GUSTAVO
OCT 14, 01:28:26
COMMENT: GWKIRK
OCT 14, 03:29:52 PM
COMMENT: STUDENT
NOV 13, 03:33:52 AM
COMMENT: JAMAL

NOV 14, 02:53:10 AM
COMMENT: GEOFF
NOV 14, 11:49:35
500 OOPS: cannot open config file:/etc/vsftpd.conf
geoff@GDR:~>
[1]+ Exit 1 /usr/sbin/vsftpd
any ideas why i get this. The server seems to work «
COMMENT: JAMAL

DEC 5, 10:53:55 AM
COMMENT: JASON WILLIAMS
DEC 6, 03:01:08 AM
Install the vsftpd package.
Modify the Firewall.
Yast -> Secruity & Users -> Firewall
Click on "Allow Services" then select "Advanced", add the following ports:
TCP Ports: ftp
UDP Ports: ftp
ftp (in lowercase) is defined within SuSE to mean ports 20 and 21
Yast -> System -> /etc/sysconfig Editor
Network -> Firewall -> SuSEfirewall2
FW_LOAD_MODULES="ip_conntrack_ftp ip_nat_ftp"
This is required for FTP NATing through a firewall. They are kernel modules and seem to require a reboot.
Edit the config file /etc/vsftpd.conf
write_enable=YES
dirmessage_enable=YES
ftpd_banner="Welcome to Womble FTP service."
local_enable=YES
local_umask=022
anonymous_enable=NO
anon_world_readable_only=YES
syslog_enable=YES
connect_from_port_20=YES
listen=YES
ssl_enable=NO
chkconfig vsftpd on
service vsftpd start
reboot «
COMMENT: FERDY
DEC 6, 07:39:40 AM
COMMENT: MAHATMA

DEC 31, 01:33:12 AM
COMMENT: JAMAL
FEB 15, 04:36:30 PM
COMMENT: FELIPE ALVAREZ

FEB 16, 06:15:10 AM
chmod 770 /srv/ftp
are both these step necessary?
How can I stop browsers from logging in automatically? «
COMMENT: DARKHELL
FEB 23, 18:56:40
COMMENT: CHUMPY
FEB 24, 14:15:17
COMMENT: MOHAMMAD
APR 27, 08:12:08 AM
instead of changing the following think vsftpd.conf chroot_local_user=YES and in vsftpd.chroot_list added user.
what else except this «
COMMENT: DIPTANJAN
MAY 1, 12:58:47 PM
Thanks a ton. Please keep posting with such wonderful articles.
Thanks again
«
COMMENT: PAUBOLIX
JUN 17, 10:14:31
500 OOPS: cannot change directory: ....
Suse 9.3 witht confixx
Any hints available?
THX! «
COMMENT: SPHIWE
JUL 9, 01:56:20 PM
COMMENT: LIMAIEM HEYKEL


SEP 29, 09:10:03 AM
COMMENT: AXE MILITARI
OCT 11, 14:06:11
Thank's. «
COMMENT: LOUIS
NOV 8, 07:07:08 AM
COMMENT: TEMESGHEN
NOV 15, 03:54:01 PM
i wish we can have this format in open community.......... «
COMMENT: ARTEM

JAN 8, 2008 - 04:50:37 PM
COMMENT: ELHAM
FEB 20, 2008 - 10:19:44 AM
instead of changing the following think vsftpd.conf chroot_local_user=YES and in vsftpd.chroot_list added user.
what else except this « «
COMMENT: ALEX
MAR 24, 2008 - 01:02:33 PM
Maybe someone can help us with this problem...
Cheers «
COMMENT: VOYANCE

APR 10, 2008 - 20:49:15
COMMENT: KATE


APR 26, 2008 - 07:13:13
COMMENT: SENNY
MAY 21, 2008 - 08:20:40
既存名刺からの作成、ロゴ追加、顔写真追加、QRコード追加や点字名刺作成も。
オンラインFX取引サイト。投資顧問、ディーリング事業を行うFX事業者。
多言語翻訳可能な翻訳会社。実績多数・高品質・安心価格の実務・技術・医薬・金融・法律の翻訳サービスを実現。WEB・DTPにも対応。
ウエディングドレスからデザイナーズ・レンタルのウエディングドレス等、低価格で全国へお届けします! «
COMMENT: BRAD


JUN 24, 2008 - 05:02:38 PM