linux系统下ftp服务器搭建教程。
安装客户端
我习惯用xftp、还有好多,看你喜欢用哪个filezilla flashfxp winscp
安装服务端
yum installvsftpd-y
systemctl start vsftpd.service#启动
这就算完事了,接下来分为2大块
1、搭建内网的
2、创建账号密码登录ftp服务器
搭建内网的文件共享服务器
内网的文件共享服务器(匿名用户,任何人都可以访问):默认存放目录是/var/ftp/pub
创建账户密码,让用户通过xftp连接ftp服
务器
useradd yangxi -s /sbin/nologin -d /home/yangxi #1、创建个普通用户用于连接ftp,-d的家目录是ftp连接上默认访问的。这个禁止登录,是禁止远程连接服务器,不是禁止登录ftp
passwd yangxi #敲回车,设置密码
配置文件/etc/vsftpd/:
ftpusers 是黑名单,禁止使用vsftpd的用户列表文件。记录不允许访问FTP服务器的用户名单
user_list 禁止或允许使用vsftpd的用户列表文件。这个文件中指定的用户缺省情况(即在/etc/vsftpd/vsftpd.conf中设置userlist_deny=YES)
2、在 vsftpd.conf 主配置文件中
anonymous_enable=YES#允许匿名用户登录,改成no
//在配置文件中添加下面这2行
local_root=/home/yangxi//修改默认根目录
chroot_local_user=YES //限制住了,只允许查看他自己的家目录
可参考:https://blog.csdn.net/bluishglc/article/details/42398811
3、改完配置文件,重启服务
服务启动不起来,点击解决报错:Job for vsftpd.service failed because the control process exited with error code. See "systemctl status vsftpd.service" and "journalctl -xe" for details
4、使用xftp客户端,连接ftp服务端
连接失败(也可能不会提示这个失败,但就是连不上,直接粘贴到配置文件中)
OOPS: chroot
关闭selinux
临时关闭
setenforce 0
永久关闭
vim /etc/selinux/config
SELINUX=disabled
连接失败(也可能不会提示这个失败,但就是连不上,直接粘贴到配置文件中)
OOPS: vsftpd: refusing to run with writable root inside chroot()
allow_writeable_chroot=YES#在vsftpd.conf 主配置文件中加入。