检查selinux,firewall,iptables是否开启
linux
[root@zeq ~] getenforce Disabled 个人如今是关闭状态
[root@zeq ~] /usr/sbin/sestatus SELinux status: disabled 个人如今是关闭状态
[root@zeq ~] setenforce 0
将SELINUX=enforcing改成SELINUX=disabled,保存后退出,reboot重启服务器后生效shell
[root@zeq ~] vim /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 # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
[root@zeq ~] systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) 我如今是关闭状态 Docs: man:firewalld(1)
[root@zeq ~] systemctl stop firewalld
[root@zeq ~] yum install vsftp -y
[root@zeq ~] systemctl start vsftpd [root@zeq ~] systemctl enable vsftpd
[root@zeq ~] cp /etc/vsftp/vsftp.conf /etc/vsftp/vsftp.conf.bak
[root@zeq ~] vim /etc/vsftp/vsftp.conf 清空原有内容插入下面的内容 anonymous_enable=NO write_enable=YES chroot_local_user=YES chroot_list_enable=YES use_localtime=YES local_enable=YES allow_writeable_chroot=YES xferlog_enable=YES local_umask=022 pam_service_name=vsftpd use_localtime=YES listen_port=21 chroot_local_user=YES idle_session_timeout=120 data_connection_timeout=120 guest_enable=YES guest_username=ftpuser user_config_dir=/etc/vsftpd/vuser_conf virtual_use_local_privs=YES pasv_min_port=10060 pasv_max_port=10090 accept_timeout=5 connect_timeout=1
/home/vsftpd
目录[root@zeq ~] useradd -g root -M -d /home/vsftpd -s /sbin/nologin ftpuser
[root@zeq ~] passwd ftpuser
[root@zeq ~] chown -R ftpuser.root /home/vsftpd
[root@zeq ~] vim /etc/vsftpd/vuser_passwd 第1、三行用户,第2、四行密码 ftp1 12345678 ftp2 12345678
[root@zeq ~] db_load -T -t hash -f /etc/vsftpd/vuser_passwd /etc/vsftpd/vuser_passwd.db [root@zeq ~] chmod 600 /etc/vsftpd/vuser_passwd.db
[root@zeq ~] mkdir /etc/vsftpd/vuser_conf # 创建虚拟用户我的vsftp的配置文件 [root@zeq ~] cd /etc/vsftpd/vuser_conf # 进入目录 [root@zeq vuser_conf] touch ftp1 ftp2 [root@zeq vuser_conf] vim ftp1 ftp2第一行改成ftp2其余内容不变 local_root=/home/vsftpd/ftp1 write_enable=YES anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES
[root@zeq ~] mkdir -p /home/vsftpd/ftp1 [root@zeq ~] mkdir -p /home/vsftpd/ftp2
[root@zeq ~] systemctl restart vsftp
[root@zeq ~] cd /etc/pam.d/ && cp vsftpd vsftpd.bak [root@zeq ~] vim /etc/pam.d/vsftpd 添加两行内容,原有内容注销 #%PAM-1.0 auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd #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
一、首先每次更改配置须要重启vsftpd服务。
二、上面每一个配置文件中的内容最好是手动键入
三、客户端windows打开cmd到后台进行链接,网页和资源管理器里面都会有缓存也看不到报错。
四、服务器tail -f /var/log/secure查看日志(也能够tail -f /var/log/messages,这个看不出什么,前者更精准)
五、客户端报错示例(没有读到/etc/vsftpd/chroot_list这个文件,因此咱们新建这个文件就行,记得重启服务)。
六、若是虚拟用户登陆到本身的宿主目录后,不能上传文件的话,服务器端须要在宿主目录里面再新建一个文件夹,给这文件夹777权限,就能够了(直接把宿主目录设置777就会登陆不了)
七、新增用户的话,须要在/etc/vsftpd/vsuser.passwd里面追加用户(删除就是删除用户),记得使用db_load从新生成vsuser.passwd文件便可,vuser_confi里面新建一个新建帐户的权限文件,宿主目录记得新建存储文件。
八、建议使用ftp工具和cmd验证
九、修改完配置或者用户信息之后必定要重启服务和从新生成vsuser.passwd(重复第八步操做)
vim
ftp 192.168.1.238 ftp命令+你服务器的ip 若是没有ftp命令yum安装便可 链接到 192.168.1.238. 220 (vsFTPd 3.0.2) 200 Always in UTF8 mode. 用户(192.168.1.238:(none)): ftp1 331 Please specify the password. 密码: 230 Login successful.
ftp> ascii # 设定以ASCII方式传送文件(缺省值) ftp> bell # 每完成一次文件传送,报警提示. ftp> binary # 设定以二进制方式传送文件. ftp> bye # 终止主机FTP进程,并退出FTP管理方式. ftp> case # 当为ON时,用MGET命令拷贝的文件名到本地机器中,所有转换为小写字母. ftp> cd # 同UNIX的CD命令. ftp> cdup # 返回上一级目录. ftp> chmod # 改变远端主机的文件权限. ftp> close # 终止远端的FTP进程,返回到FTP命令状态, 全部的宏定义都被删除. ftp> delete # 删除远端主机中的文件. ftp> dir [remote-directory] [local-file] # 列出当前远端主机目录中的文件.若是有本地文件,就将结果写至本地文件. ftp> get [remote-file] [local-file] # 从远端主机中传送至本地主机中. ftp> help [command] # 输出命令的解释. ftp> lcd # 改变当前本地主机的工做目录,若是缺省,就转到当前用户的HOME目录. ftp> ls [remote-directory] [local-file] # 同DIR. ftp> macdef # 定义宏命令. ftp> mdelete [remote-files] # 删除一批文件. ftp> mget [remote-files] # 从远端主机接收一批文件至本地主机. ftp> mkdir directory-name # 在远端主机中创建目录. ftp> mput local-files # 将本地主机中一批文件传送至远端主机. ftp> open host [port] # 从新创建一个新的链接. ftp> prompt # 交互提示模式. ftp> put local-file [remote-file] # 将本地一个文件传送至远端主机中. ftp> pwd # 列出当前远端主机目录. ftp> quit # 同BYE. ftp> recv remote-file [local-file] # 同GET. ftp> rename [from] [to] # 改变远端主机中的文件名. ftp> rmdir directory-name # 删除远端主机中的目录. ftp> send local-file [remote-file] # 同PUT. ftp> status # 显示当前FTP的状态. ftp> system # 显示远端主机系统类型. ftp> user user-name [password] [account] # 从新以别的用户名登陆远端主机. ftp> ? [command] # 同HELP. [command]指定须要帮助的命令名称。若是没有指定 command,ftp 将显示所有命令的列表。 ftp> ! # 从 ftp 子系统退出到外壳。