5.linux搭建ftp服务
1、配置本地yum 源
[root@localhost ~]# cat /etc/yum.repos.d/local.repo
[aa]
name=aa
baseurl=file:///dev/liuyan
gpgcheck=0
enabled=1
2、设置关闭防火墙
[root@localhost ~]# systemctl stop firewalld
setenforce 0
3、关闭selinux
[root@localhost ~]# cat /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=diasbled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
4、安装vsftpd
[root@localhost ~]# yum install vsftpd -y
查看软件是否安装
[root@localhost ~]# rpm -qa vsftpd
vsftpd-3.0.2-27.el7.x86_64
配置文件说明
/etc/vsftpd/vsftpd.conf 是 vsftpd 的核心配置文件。 /etc/vsftpd/ftpusers 是黑名单文件,此文件里的用户不允许访问 FTP 服务器。 /etc/vsftpd/user_list 是白名单文件,此文件里的用户允许访问 FTP 服务器。
5、配置vsftpd
创建本地用户
设置本地用户密码
[root@localhost ~]# useradd ftptest
[root@localhost ~]# echo '123456' | passwd --stdin ftptest
Changing password for user ftptest.
passwd: all authentication tokens updated successfully.
更改 /var/ftp/test 目录的拥有者为 ftptest
[root@localhost ~]# mkdir /var/ftp/test
[root@localhost ~]# chown ftptest:ftptest /var/ftp/test -R
备份配置文件
[root@localhost ~]# cd /etc/vsftpd/
[root@localhost vsftpd]# ll
total 20
-rw-------. 1 root root 125 Apr 1 12:55 ftpusers
-rw-------. 1 root root 361 Apr 1 12:55 user_list
-rw-------. 1 root root 5116 Apr 1 12:55 vsftpd.conf
-rwxr--r--. 1 root root 338 Apr 1 12:55 vsftpd_conf_migrate.sh
[root@localhost vsftpd]# cp vsftpd.conf vsftpd.conf.bak
修改配置文件
[root@localhost vsftpd]# egrep -v "^#|^$" vsftpd.conf
anonymous_enable=NO
local_enable=YES
local_root=/var/ftp/test
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
xferlog_std_format=YES
chroot_local_user=YES
pasv_enable=YES
pasv_address=192.168.78.128
pasv_min_port=10000
pasv_max_port=10088
listen=YES
listen_ipv6=NO
pam_service_name=vsftpd
userlist_enable=YES
download_enable=YES
allow_writeable_chroot=YES
[root@localhost vsftpd]#
6、可以查看
[root@localhost ~]# ftp 192.168.78.128
Connected to 192.168.78.128 (192.168.78.128).
220 (vsFTPd 3.0.2)
Name (192.168.78.128:root): ftptest
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ll
?Invalid command
ftp> ls
227 Entering Passive Mode (192,168,78,128,39,30).
150 Here comes the directory listing.
drwxr-xr-x 2 1001 1001 6 Sep 01 05:45 test
226 Directory send OK.
ftp>

参考文档 https://www.cnblogs.com/yanjieli/p/10697671.html

浙公网安备 33010602011771号