注:ftp只能走相对路径传输文件,需要先cd到文件路径,然后ftp登陆,put上传,get下载

1. 装包与卸载

yum -y install vsftpd

yum -y autoremove vsftpd&&rm -rf /etc/vsftpd

2. 配置

先看相关文件介绍

[root@haproxy2 ~]# ls /etc/vsftpd/
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@haproxy2 ~]# head -1 /etc/vsftpd/ftpusers #黑名单:拒绝用户清单
# Users that are not allowed to login via ftp
[root@haproxy2 ~]# head -6 /etc/vsftpd/user_list #白名单:允许用户清单,添加的新用户需要追加到此文件中
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
[root@haproxy2 ~]# echo myftp >> /etc/vsftpd/user_list 

再根据需要修改配置文件

[root@haproxy2 ~]# grep userlist /etc/vsftpd/vsftpd.conf
userlist_enable=YES
[root@haproxy2 ~]# echo userlist_deny=NO >> /etc/vsftpd/vsftpd.conf
[root@haproxy2 ~]# grep -n userlist /etc/vsftpd/vsftpd.conf
126:userlist_enable=YES
127:userlist_deny=NO
[root@haproxy2 ~]# useradd -m myftp -d /home/myftp -s /sbin/nologin
[root@haproxy2 ~]# echo myftp | passwd myftp --stdin
Changing password for user myftp.
passwd: all authentication tokens updated successfully.
[root@haproxy2 ~]# chmod -R 755 /home/myftp #权限很关键,nologin默认700的权限,ftp登陆后会无法上传文件
[root@haproxy2 ~]# vi /etc/vsftpd/vsftpd.conf   #修改ftp目录
128:anon_root=/home/myftp 
129:local_root=/home/myftp
[root@haproxy2 ~]# grep -nE 'local_root |anon_root|chroot_' /etc/vsftpd/vsftpd.conf  #以下视需要而选择是否配置
95:# directory. If chroot_local_user is YES, then this list becomes a list of
100:#chroot_local_user=YES
101:#chroot_list_enable=YES
103:#chroot_list_file=/etc/vsftpd/chroot_list
[root@haproxy2 ~]# grep -nE 'local_root|anon_root|chroot_' /etc/vsftpd/vsftpd.conf #设置local_root切换默认目录,要切换目录必须开放chroot_list
95:# directory. If chroot_local_user is YES, then this list becomes a list of
100:chroot_local_user=YES
101:chroot_list_enable=YES
103:chroot_list_file=/etc/vsftpd/chroot_list

[root@haproxy2 ~]# echo myftp >> /etc/vsftpd/chroot_list

最后改一下pam文件,这一步非常关键,否则nologin的用户登陆不进来,但此配置可能会影响到lftp,sftp,xftp等服务

[root@haproxy2 ~]# cat /etc/pam.d/vsftpd
#%PAM-1.0
session optional pam_keyinit.so force revoke
auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
auth required pam_shells.so
auth include password-auth
account include password-auth
session required pam_loginuid.so
session include password-auth [root@haproxy2 ~]# sed -i 's/pam_shells/pam_nologin/' /etc/pam.d/vsftpd
[root@haproxy2 ~]# systemctl restart vsftpd

查看目录

!代表非ftp内部命令,即本地操作命令。

!+命令,跟shell脚本有相似之处,从当前目录开始执行,结束后会到当前目录

如:!cd /home/oracle&&pwd;    #看到的会是/home/oracle ;然后再次!pwd 看到的还是当前目录,而不是/home/oracle

ftp> pwd  #ftp的主目录
257 "/"
ftp> !pwd #登陆ftp前所在的本地目录
/root
ftp>

最新文章

  1. text()和html()的区别,以及val()
  2. DOM操作基础
  3. GCD 大中枢派发 简单应用实例
  4. 在Ecshop后台打印订单页面将商品按货号排序
  5. hdu4632 Palindrome subsequence ——区间动态规划
  6. zipline
  7. Cocos2d-X中实现菜单特效
  8. 三个C++资源链接(大量)
  9. CentOS-6.5x64:SSH安装配置
  10. 蓝桥杯-四平方和-java
  11. 第二章:2.8 通过Django 在web页面上面输出 “Hello word ”
  12. 【ES】学习11-多桶排序
  13. JavaWeb开发如何用Tomcat部署发布
  14. hdu4289 Control 最大流最小割
  15. (原创)一个简洁通用的调用DLL函数的帮助类
  16. 从Web抓取信息的几个常用方法
  17. SQL中注意数据类型对性能的影响
  18. Nginx入门篇(六)之反向代理和负载均衡
  19. 关于 拼接 url 连接 参数的问题(爬虫)。
  20. orcl 对table的一些操作

热门文章

  1. nginx的安装和配置
  2. LFS(Linux From Scratch)构建过程全记录(七):进入Chroot并构建临时工具
  3. 华南理工大学 Python第4章课后小测-2
  4. VMware Component Manager服务无法启动
  5. 在Windows客户端自动设置AD用户头像
  6. Nginx服务器性能优化与安全配置实践指南
  7. 使用kubeoperator安装的k8s集群配置Ingress规则有关说明
  8. 查看docker容器占用的内存
  9. 11. Fluentd部署:性能优化
  10. 谣言检测——(PSA)《Probing Spurious Correlations in Popular Event-Based Rumor Detection Benchmarks》