21 May 2011

VSftpd with virtual users and working!

[1]

put the below on the file /etc/vsftpd.conf

listen=YES

anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES

pam_service_name=vsftpd.virtual

guest_enable=YES

user_sub_token=$USER

local_root=/var/www/sites/$USER

chroot_local_user=YES

##chown_uploads=YES
##chown_username=ftp

hide_ids=YES

[2]

put the below on the file /etc/pam.d/vsftpd.virtual

#%PAM-1.0
auth       required     pam_userdb.so db=/etc/vsftpd/v-users crypt=hash
account    required     pam_userdb.so db=/etc/vsftpd/v-users crypt=hash
session    required     pam_loginuid.so

[3]

install these packages:

yum install db4-utils db4

[4]

last steps:

cd /etc/vsftpd
echo user1 > passwd.txt
echo user1passs >> passwd.txt

[a] db_load -T -t hash -f passwd.txt v-users.db
[b] chmod 600 v-users.db
[c] rm -f passwd.txt

to add additional users, repeat steps a-b-c

[5]

creating the directory where the files will be:

mkdir /var/www/sites
mkdir -p /var/www/sites/{user1,user2}
chown -R ftp:ftp /var/www/sites

put the files in the folder to download User:

eg: cp /etc/motd /var/www/sites/user1

service vsftpd restart

ftp ftp-ip-server

user: user1
pass: user1pass


[6]

Troubleshooting:

tail -30 /var/log/secure

tail -30 /var/log/messages

[7]

put in the ftpd daemon startup:

chkconfig vsftpd on


biOos

No comments: