linux笔记
查看是否安装:
Rpm -q vsftpd
[root@localhost ~]# cd /run/media/root/CentOS\ 7\ x86_64/Packages/
[root@localhost Packages]# ls | grep vsftpd
vsftpd-3.0.2-22.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh vsftpd-3.0.2-22.el7.x86_64.rpm
[root@localhost Packages]# rpm -q vsftpd
vsftpd-3.0.2-22.el7.x86_64
[root@localhost Packages]# systemctl stop firewalld
[root@localhost Packages]# systemctl status firewalld
root@localhost Packages]# setenforce 0
[root@localhost Packages]# getenforce
Permissive
[root@localhost Packages]# systemctl start vsftpd
t@localhost Packages]# systemctl status vsftpd 查看是否启动成功
在客户端浏览器中ftp://192.168.101.2可以看到文件,暂时无法下载上传
[root@localhost Packages]# rpm -q ftp
package ftp is not installed
[root@localhost Packages]# cd /run/media/root/CentOS\ 7\ x86_64/Packages/
[root@localhost Packages]# ls | grep ftp
ftp-0.17-67.el7.x86_64.rpm
lftp-4.4.8-8.el7_3.2.x86_64.rpm
tftp-5.2-22.el7.x86_64.rpm
tftp-server-5.2-22.el7.x86_64.rpm
vsftpd-3.0.2-22.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh ftp-0.17-67.el7.x86_64.rpm
在客户端中登录FTP服务时,服务器没有设置账户,则可用匿名账户登录,用户名为FTP密码为空。
[root@localhost ~]# ftp 192.168.101.2
Connected to 192.168.101.2 (192.168.101.2).
220 (vsFTPd 3.0.2)
Name (192.168.101.2:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
exit从ftp服务器中退出
在服务器中ftp对应的目录:
[root@localhost ~]# cd /var/ftp/
从服务器中下载文件:get test.file
上传到FTP服务器中:put index.html 报错550被拒绝
匿名用户只能下载无法上传文件。
服务器端为了让匿名用户上传文件需要修改:
[root@localhost pub]# vim /etc/vsftpd/vsftpd.conf
将这两句注释取消掉
anon_upload_enable=YES
anon_mkdir_write_enable=YES
编辑配置后需要重启:
Systemctl restart vsftpd
Systemctl status vsftpd
在客户机中再次上传文件:
ftp> put index.html
local: index.html remote: index.html
227 Entering Passive Mode (192,168,101,2,28,152).
553 Could not create file.
权限不足
回到服务器中查看文件的权限
[root@localhost pub]# ll -d /var/ftp/pub
Drwx r-x r-x. 2 root root 23 Mar 5 06:13 /var/ftp/pub
匿名用户只有rx权限,没有w的权限
[root@localhost pub]# chmod o+w /var/ftp/pub/ o+w是other用户加上写的权限
[root@localhost pub]# ll -d /var/ftp/pub
drwxr-xrwx. 2 root root 23 Mar 5 06:13 /var/ftp/pub
在客户机中exit退出再登录到ftp服务器上,进入到cd pub/目录
ftp> put index.html
local: index.html remote: index.html
227 Entering Passive Mode (192,168,101,2,89,120).
150 Ok to send data.
226 Transfer complete.
19 bytes sent in 8.4e-05 secs (226.19 Kbytes/sec)
上传成功,再回到服务器中查看,
[root@localhost pub]# ls
index.html test.file
[root@localhost pub]# ll
total 8
-rw-------. 1 ftp ftp 19 Mar 5 06:27 index.html
-rw-r--r--. 1 root root 16 Mar 5 06:12 test.file
[root@localhost pub]# cat index.html
12314545645313knan
OK

1万+

被折叠的 条评论
为什么被折叠?



