美文网首页
Centos7安装搭建FTP服务器

Centos7安装搭建FTP服务器

作者: 中v中 | 来源:发表于2022-07-05 10:17 被阅读0次

一、查看是否已经安装了vsftpd

vsftpd -version

二、安装vsftpd

yum install -y vsftpd

三、新建FTP目录
创建的FTP目录 /data/ftp

mkdir -p /data/ftp

四、创建新用户
guoke为你为该ftp创建的用户名,/data/ftp 为登录进去后的位置

useradd -d /data/ftp -s /bin/bash guoke

五、为新建的用户设置密码

passwd guoke

六、设置主目录

更改登录时看到的目录,看个人需要更改,如果第4步已设置好,此步可忽略

usermod -d /data/ftp guoke

七、设置目录权限

将/data/ftp目录权限设置为guoke用户,否则ftp客户端将无法写入文件

chown -Rc guoke. /data/ftp

八、防火墙添加FTP服务

firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload

九、修改Selinux

setsebool -P ftpd_full_access on

十、配置只能访问自身目录

vim /etc/vsftpd/vsftpd.conf
#去掉前面的注释
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
ascii_upload_enable=YES
ascii_download_enable=YES
chroot_local_user=YES
chroot_list_enable=NO
chroot_list_file=/etc/vsftpd/chroot_list
listen=NO

#文件末尾添加
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
allow_writeable_chroot=YES
local_root=/data/ftp
# 速度放开
#比如你想限制本地用户的上传速度和下载速度为1MB/s,则在vsftpd.conf中添加以下内容:
local_max_rate = 1048576

#※ 默认单位是Byte/s

在chroot_list中添加guoke用户
vim /etc/vsftpd/chroot_list

把ftp用户guoke写入

保存
十一、启动、重启

启动

systemctl start  vsftpd.service

停止

systemctl stop  vsftpd.service

设置开机启动

systemctl enable vsftpd.service

十二、禁止ftp用户ssh登录

由于需要限制ftp用户在自己的目录,在21端口下没有问题,但当ftp用户用sftp登录时,还是可以访问上级目录,于是禁止ftp用户ssh登录,切断22端口的通信。

查看/etc/shells文件,看禁止登录的shell为/usr/sbin/nologin。如果没有,在文件后面添加

usermod -s /usr/sbin/nologin guoke

如果要恢复guoke的ssh登录

usermod -s /bin/bash guoke

mac 操作
ftp
open ip
user
password

put
get

如果putget出现问题500,
500 Illegal PORT command.
需要输入命令 passive 模式
ftp> passive

相关文章

网友评论

      本文标题:Centos7安装搭建FTP服务器

      本文链接:https://www.haomeiwen.com/subject/asrrbrtx.html