(1) Install vsftpd, if installed, ignore.
=> # yum install vsftpd
(2) Start vsftpd
=> # service vsftpd start
=> # chkconfig --level 35 vsftpd on // If start vsftpd when os starts, run command,
解析: chkconfig --level 35 vsftpd on : 设定vsftpd在等级3和5为开机运行服务,--level 35表示操作只在等级3和5执行,on表示启动,off表示关闭
(3) 主要目录及配置文件
=> (1) /etc/vsftpd/ => config, user_list, ftpusers, chroot_list and so on.
vsftpd.ftpusers:位于/etc目录下。它指定了哪些用户账户不能访问
FTP服务器,例如root等。
vsftpd.user_list:位于/etc目录下。该文件里的用户账户在默认情况下也不能访问
FTP服务器,仅 当vsftpd .conf配置文件里启用userlist_enable=NO选项时才允许访问。
vsftpd.conf:位于/etc/vsftpd目录下。来自定义用户登录控制、用户权限控制、超时设置、服务器功能选项、服务器性能选项、服务器响应消息等
FTP服务器的配置。
主要的配置:
anonymous_enable=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
=> (2) /etc/pam.d/vsftpd => pam secure issue.
这个涉及到权限问题,有时需要屏蔽掉
#auth required pam_shells.so
(4) 设置用户
=> # useradd -d /home/user user // 创建用户并设定目录
# passwd user // 设置密码
# usermod -s /sbin/nologin user //不能用shelll登陆
=> userdel user // 删除用户
(5) 设置访问权限
=> 如果想用户拥有访问别的目录的权限,需要打开chroot_list_enable=YES和chroot_list_file=/etc/vsftpd.chroot_list并把用户名放到里面。
(6) 常见登陆拒绝问题。
=> 若被拒绝登陆,删除
/etc/vsftpd/user_list里面对应的用户名。
=> 550 Create directory operation failed
#
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing (
把默认的改成disabled)
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
然后重启就ok了。
(7) 为了方便,在用户目录下可以建 .netrc 文件
在当前用户的主目录创建一个.netrc文件,权限设置600
文件内容是:
machine 192.168.0.1
login ftpuser
password ftpuser_password
后面每次登陆时就不用再输入密码了