1.安装vsftpd
2.配置匿名用户ftp
3.配置虚拟用户ftp
4.配置本地用户ftp
5.写明ftp的使用场景以及如何安装与配置
要求:
1.安装并配置完成后要使用ftp客户端工具登录配置
1.ftp的使用场景
1.服务器与用户端之间进行档案的传输
2.数据的备份
2.安装与配置
1.安装前准备
[root@localhost ~]# yum install vsftpd epel-release -y 安装vsftpd和epel-release服务
[root@localhost ~]# systemctl stop firewalld.service 关闭防火墙
2.配置匿名用户
1.配置
[root@localhost ~]# cat /etc/passwd | grep ftp 查看ftp的家目录
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
[root@localhost ftp]# vim /etc/vsftpd/vsftpd.conf
anon_upload_enable=YES 允许匿名用户上传
anon_other_write_enable=YES 允许匿名用户创建和删除目录
[root@localhost ~]# systemctl start vsftpd 启动vsftpd服务
2.查看效果
.1主机端
[root@localhost ~]# chmod 777 /var/ftp/pub/ 给文件完全权限,不然匿名用户无法上传文件
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# ls
pub
[root@localhost ftp]# touch hello-world
[root@localhost ftp]# ls
hello-world pub
2.FTP软件查看效果
上传文件
3.主机端查看效果
[root@localhost ~]# cd /var/ftp/pub/
[root@localhost pub]# ll
总用量 4
-rw------- 1 ftp ftp 13 9月 12 18:34 新建文本文档 (2).txt
3.配置虚拟用户(虚拟用户是匿名访问,必须开启匿名访问)
1。创建虚拟用户
[root@localhost ~]# echo 'kong' >> /etc/vsftpd/vu.list 添加用户名和密码
[root@localhost ~]# echo '123' >> /etc/vsftpd/vu.list
[root@localhost ~]# cat /etc/vsftpd/vu.list
kong
123
[root@localhost ~]# yum install db4* -y 安装db4工具
[root@localhost ~]# db_load -T -t hash -f /etc/vsftpd/vu.list /etc/vsftpd/vu.db 转换文件为数据库文件
[root@localhost ~]# chmod 600 /etc/vsftpd/vu.* 保证用户账号文件安全性,谁知为600
[root@localhost ~]# ll /etc/vsftpd/vu.*
-rw------- 1 root root 12288 9月 12 18:42 vu.db
-rw------- 1 root root 9 9月 12 18:39 vu.list
2.添加虚拟用户的映射账号
[root@localhost ~]# useradd -d /var/kongbai/ -s /sbin/nologin bais 映射账号为bais
[root@localhost ~]# chmod 755 /var/kongbai/
[root@localhost ~]# vim /etc/pam.d/vsftpd 最好备份一下这个文件,全部删除,添加内容
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd.vu
account required pam_userdb.so db=/etc/vsftpd.vu
[root@localhost ~]# echo 'guest_enable=YES' >> /etc/vsftpd/vsftpd.conf
[root@localhost ~]# echo 'guest_username=bais' >> /etc/vsftpd/vsftpd.conf
3.查看效果
1.主机端
[root@localhost ~]# cd /var/kongbai/
[root@localhost kongbai]# touch hello-world
[root@localhost kongbai]# ls
hello-world
2.FTP软件
上传文件
3.主机端
[root@localhost kongbai]# ll
总用量 4
-rw-r--r-- 1 root root 0 9月 12 19:05 hello-world
-rw------- 1 bais bais 13 9月 12 19:06 新建文本文档 (2).t
4.配置本地用户
1.配置
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf 添加以下两行,有的话可以不加
local_enable=YES
write_enable=YES
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# useradd kongcheng 创建用户名和密码
[root@localhost ~]# passwd kongcheng
[root@localhost ~]# cat /etc/passwd | grep kongcheng 查询创建的用户的家目录
kongcheng:x:1001:1001::/home/kongcheng:/bin/bash
[root@localhost home]# cd /home/kongcheng/0
[root@localhost kongcheng]# ll -d
drwx------ 3 kongcheng kongcheng 78 9月 13 10:22 . 家目录的所有者必须是刚刚创建的用户
2.查看效果
1.用户端
2.主机端添加文件
[root@localhost kongcheng]# touch hello-world
[root@localhost kongcheng]# ls
hello-world
3.用户端查看
上传文件
4.主机端查看
[root@localhost kongcheng]# ls
hello-world TIM截图20180912190649.png