DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 21st October 2008
disappearedng disappearedng is offline
Shell Scout
 
Join Date: May 2008
Posts: 128
Default VSFTPD Server Issues!!

Hi everyone
I followed the guide provided by vsftp's examples and I can't get my desired username and password to work.

1) I have create a file in /etc/
Code:
[root@192 /usr/local/etc]# cat /etc/logins.txt 
jojo
zhoufengping
2) I loaded the file into berkeleyDB
Code:
db_load-4.2 -T -t hash -f logins.txt /etc/vsftp_login.db 
chmod 600 /etc/vsftpd_login.db
3) I Created a pam file, /etc/pam.d/vsftpd.pam
Code:
[root@192 /etc]# cat /etc/pam.d/vsftpd.pam 
auth    required /usr/local/lib/pam_pwdfile.so pwdfile /etc/vsftpd_login.db
account required /usr/lib/pam_permit.so
4) I created a new user virtual with NO PASSWORD
[code]
cat /etc/passwd | grep virtual
virtual:*:1002:1006:virtual:/usr/mount/50gb/ftp:/usr/sbin/nologin
[code]

5) And then I followed the guide and copied /etc/hosts to my ftp area
Code:
cp /etc/hosts /usr/mount/50gb/ftp/
chown virtual:virtual /usr/mount/50gb/ftp/hosts
6) Now this is my conf
Code:
[root@192 /etc]# cat /usr/local/etc/vsftpd.conf
anonymous_enable=NO
local_enable=YES

write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO

chroot_local_user=YES

guest_enable=YES
guest_username=virtual

listen=YES
listen_port=21

secure_chroot_dir=/usr/local/share/vsftpd/empty
7) And I started my server
/usr/local/libexec/vsftp &
No error

8)However, when I try to login,
Code:
[root@192 /etc]# ftp localhost
Trying 127.0.0.1...
Connected to localhost.
220 (vsFTPd 2.0.7)
Name (localhost:root): zhou
331 Please specify the password.
Password:
530 Login incorrect.
ftp: Login failed.
ftp> close
221 Goodbye.
ftp> ftp localhost
Trying 127.0.0.1...
Connected to localhost.
220 (vsFTPd 2.0.7)
Name (localhost:root): virtual
331 Please specify the password.
Password:
530 Login incorrect.
ftp: Login failed.
ftp> close
221 Goodbye.
ftp>
None of my user names work.

What the hell is wrong? Why can't vsftp read my database generated by db_load???
Reply With Quote
  #2   (View Single Post)  
Old 21st October 2008
J65nko J65nko is online now
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

From /usr/local/share/doc/db4/utility/db_load.html of my OpenBSD box
Quote:
-T
The -T option allows non-Berkeley DB applications to easily load text files into databases.

If the database to be created is of type Btree or Hash, or the keyword keys is specified as set, the input must be paired lines of text, where the first line of the pair is the key item, and the second line of the pair is its corresponding data item.
So the login.txt needs to be
Code:
jojo
jojos_secret_password
zhoufengping
zhoufengpings_secret_password
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 22nd October 2008
disappearedng disappearedng is offline
Shell Scout
 
Join Date: May 2008
Posts: 128
Default

I am still not getting that to work.

Do you have a good ftp server to recommend?
Reply With Quote
  #4   (View Single Post)  
Old 22nd October 2008
J65nko J65nko is online now
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

vsftp is regarded by many as the most secure one. Bob Beck, OpenBSD developer and system admin at the Canadian Alberta University uses vsftpd for the OpenBSD.org ftp site, kindly hosted by the university.

Over the weekend I have some time to play with vsftp. Will try to get the thing working for you
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #5   (View Single Post)  
Old 24th October 2008
disappearedng disappearedng is offline
Shell Scout
 
Join Date: May 2008
Posts: 128
Default

Dear J65nko,
Thanks a lot man.
Please document everything that you do.
The vsftpd community on IRC is virtually non existent.

You can email me @ disappearedng@gmail.com

thx
Reply With Quote
  #6   (View Single Post)  
Old 24th October 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Default

Hi!

The right way to fire up your vsftpd server is the following:

1. Create the /etc/pam.d/vsftpd
Code:
auth required /usr/local/lib/pam_pwdfile.so pwdfile /etc/vsftpd_login.db
account required /usr/lib/pam_permit.so
2. Create the user virtual users will be mapped to - virtual for example:
Code:
# adduser -v
Username: virtual
Full name: Virtual FTP user
Uid (Leave empty for default):
Login group [virtual]:
Login group is virtual. Invite virtual into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash rbash nologin) [sh]: nologin
Home directory [/home/virtual]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username   : virtual
Password   : *****
Full Name  : Virtual FTP user
Uid        : 1007
Class      :
Groups     : virtual
Home       : /home/virtual
Shell      : /usr/sbin/nologin
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (virtual) to the user database.
Add another user? (yes/no): no
Goodbye!
3. Create the password database for vsftpd with the htpasswd tool - /etc/vsftpd_login.db
Code:
htpasswd -c -b /etc/vsftpd_login.db USERNAME PASSWORD
4. Create the vsftpd.conf file - this is mine
Code:
anonymous_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
anon_world_readable_only=NO

listen=YES
listen_address=x.x.x.x
listen_port=21

max_clients=200 # change these to whatever you want
max_per_ip=5

write_enable=NO
local_enable=YES
pam_service_name=vsftpd

pasv_min_port=50000 # change these too if you have a firewall running
pasv_max_port=50999 

xferlog_enable=YES

chroot_local_user=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty/

guest_enable=YES
guest_username=virtual

ls_recurse_enable=NO
ascii_download_enable=NO
ascii_upload_enable=NO
5. Fire up your vsftpd server
Code:
# /usr/local/libexec/vsftpd &
6. Start using vsftpd

That's it - I needed an ftp server and today I decided to install vsftpd. This is how I did it and it works like a charm

Cheers,
DNAeon
__________________
"I never think of the future. It comes soon enough." - A.E

Useful links: FreeBSD Handbook | FreeBSD Developer's Handbook | The Porter's Handbook | PF User's Guide | unix-heaven.org
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to configure VSFTPD? Sunsawe FreeBSD Ports and Packages 8 26th September 2009 02:28 PM
VSFTPD SERVER disappearedng FreeBSD General 1 21st October 2008 04:12 AM
FreeBSD Server issues Crypt FreeBSD General 4 10th October 2008 07:44 PM
VSFTPd: pid file kostromin FreeBSD Ports and Packages 0 4th July 2008 08:35 AM
vsftpd stucks in close() sunnyone FreeBSD Ports and Packages 0 10th June 2008 10:49 AM


All times are GMT. The time now is 02:00 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick