- 论坛徽章:
- 0
|
Freebsd ports安装vsftpd 虚拟用户(pwdfile)
cd /usr/ports/ftp/vsftpd/
make install
cd /usr/ports/security/pam_pwdfile
make install
pw add user ftp -d /var/ftp -s /usr/sbin/nologin
chown -R ftp:wheel /var/ftp
mkdir -p /usr/local/share/vsftpd/empty/
#Freebsd 5之前版本 修改/etc/pam.conf,增加
----------------------------------------
vsftpd auth required /usr/local/lib/pam_pwdfile.so pwdfile /etc/vsftpd/passwd_ftp
vsftpd account required pam_permit.so
----------------------------------------
#Freebsd 5 之后版本 修改 /etc/pam.d/vsftpd (若无此文件,请创建)为
----------------------------------------
auth required /usr/local/lib/pam_pwdfile.so pwdfile /etc/vsftpd/passwd_ftp
account required pam_permit.so
----------------------------------------
#修改/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=ftp
listen=YES
listen_port=21
pasv_min_port=30000
pasv_max_port=30999
pam_service_name=vsftpd
user_config_dir=/etc/vsftpd/userconf/
ftpd_banner=Welcome to FB ftp service
----------------------------------------
mkdir -p /etc/vsftpd/userconf/
#新增用户test 密码test
#创建test用户配制文件 /etc/vsftpd/userconf/test
echo 'local_root=/var/ftp/test/' >>/etc/vsftpd/userconf/test
#增添passwd_ftp
echo 'test:$1$2pn7EVn0$wsMScd/8KmaWHLBx4dLN71' /etc/vsftpd/passwd_ftp
创建md5pwd.pl,运行perl md5pwd.pl user:userpasswd 生成加密的密码.将生成的密码写入/etc/vsftpd/passwd_ftp
#! /usr/bin/perl -w
#filename: md5pwd.pl
use strict;
#
#
print "#example: user:passwd\n";
while (STDIN>) {
exit if ($_ =~/^\n/);
chomp;
(my $user, my $pass) = split /:/, $_, 2;
my $crypt = crypt $pass, '$1$' . gensalt(8);
print "$user:$crypt\n";
}
sub gensalt {
my $count = shift;
my @salt = ('.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z');
my $s;
$s .= $salt[rand @salt] for (1 .. $count);
return $s;
}
运行vsftpd
/usr/local/libexec/vsftpd &
ftp localhost 测试...
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/18586/showart_673611.html |
|