既然强调快速, 我们就马上开始,环境是centos5安装vsftpd,用了半天做了测试与修改,终于完成。
第一步:安装vsftpd,在终端允许
# yum -y install vsftpd
没什么问题就直接安装好啦
第二步:编辑vsftpd的配置文件
# vi /etc/vsftpd/vsftpd.conf
第三步:清空文件, 然后添加如下内容:
listen=YES
background=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=NO
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
async_abor_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to hao32 FTP servers
pam_service_name=vsftpd
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
第四步:终端运行下面命令
# touch /etc/vsftpd/chroot_list
# service vsftpd start
如果出现下面这句话:
Starting vsftpd for vsftpd: [ OK ]
则表示成功,如果不行则用这个语句:
ftp默认我们使用系统用户, 现在我们来添加用户chenwd, 指向目录/home/chenwd, 权限是nologin, 就是没给shell权限, 不影响ftp的
# useradd chenwd -d /home/chenwd -s /sbin/nologin
如果显示
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
不用理会, 只是告诉你, 你指向的目录已经存在了, 这不影响
设置目录及其文件的属组, 你也可以使用别的分组方式
# chown -R chenwd.chenwd /home/hao32
把用户chenwd加到/etc/vsftpd/chroot_list里, 这样用户就可以正常登陆并且不能跳出自己的目录
# echo ‘hao32′ >> /etc/vsftpd/chroot_list
# service vsftpd restart
# passwd chenwd
完毕! 测试登陆吧
ftp主机: 服务器IP地址
ftp用户: hao32
ftp密码: 你自己刚才设置的
若出现如何报错:
C:\Documents and Settings\Administrator>ftp 218.62.70.104
Connected to 218.62.70.104.
220 Welcome to blah FTP service.
User (218.62.70.104:(none)): chenwd
331 Please specify the password.
Password:
500 OOPS: could not open chroot() list file:/etc/vsftpd/chroot_list
500 OOPS: priv_sock_get_result
Connection closed by remote host.
其实很简单,chroot_list这个文件不存在,执行touch /etc/vsftpd/chroot_list就可以了。
但做完之后错误变成了这个:
C:\Documents and Settings\Administrator>ftp 218.62.70.104
Connected to 218.62.70.104.
220 Welcome to blah FTP service.
User (218.62.70.104:(none)): chenwd
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/chenwd
500 OOPS: child died
Connection closed by remote host.
都是讨厌的selinux惹得祸,执行如下操作即可:
# setsebool ftpd_disable_trans 1
# service vsftpd restart
若绝对麻烦,可干脆关掉selinux。
修改/etc/selinux/config
把SELINUX改成disabled,重启就可以了。
转载于:https://blog.51cto.com/mycnarms/655054