标签:ftp
yum -y install vsftpd
mkdir /etc/vsftpd/vuser_conf
cat /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
ascii_upload_enable=YES
ascii_download_enable=YES
chroot_list_enable=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=ftp
user_config_dir=/etc/vsftpd/vuser_conf
dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
pasv_enable=YES
pasv_min_port=5000
pasv_max_port=6000
pasv_promiscuous=NO
cat /etc/vsftpd/vuser_passwd.txt
liuly //用户名
1234567 //密码
db_load –T –t hash –f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db
cat /etc/pam.d/vsftpd
#session optional pam_keyinit.so force revoke
#auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
#auth required pam_shells.so
#auth include password-auth
#account include password-auth
#session required pam_loginuid.so
#session include password-auth
auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd
account required pam_userdb.so db=/etc/vsftpd/vuser_passwd
cat /etc/vsftpd/vuser_conf/liuly
local_root=/data/liuly
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
/etc/init.d/vsftpd restart
PS:
增加用户
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "./$0 USER"
exit 1
fi
USER=$1
WORKDIR=/etc/vsftpd
USERFILE=$WORKDIR/vuser_passwd.txt
USERCONF=$WORKDIR/vuser_conf/$USER
grep -q -w "$USER" $USERFILE
if [ "$?" -eq 0 -o -d "/data/$USER" ]; then
echo "ERROR: $USER already exist!"
exit 1
fi
mkdir -p /data/$USER
chown -R ftp:ftp /data/$USER
cat > $USERCONF << EOF
local_root=/data/$USER
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
EOF
python=`which python`
password_script="create_passwd.py"
password=$($python $password_script)
echo "$USER" >> $USERFILE
echo "$password" >> $USERFILE
db_load=`which db_load`
$db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db
/etc/init.d/vsftpd restart
echo
echo "ftp_ip : project.ftp.xinghegame.com"
echo "ftp_user : $USER"
echo "ftp_password: $password"
echo "ftp_port : 21"
#!/usr/bin/env python
import random
import string
def create_password(lenth=16):
s = string.letters + string.digits + ‘!@#$%^&*_+‘
passwd = ‘‘.join(random.sample(s, lenth))
return passwd
print create_password()
标签:ftp
原文地址:http://leyin01.blog.51cto.com/9062123/1844378