centos8安装vsftpd
2024-10-20 03:48:25
注: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>
最新文章
- text()和html()的区别,以及val()
- DOM操作基础
- GCD 大中枢派发 简单应用实例
- 在Ecshop后台打印订单页面将商品按货号排序
- hdu4632 Palindrome subsequence ——区间动态规划
- zipline
- Cocos2d-X中实现菜单特效
- 三个C++资源链接(大量)
- CentOS-6.5x64:SSH安装配置
- 蓝桥杯-四平方和-java
- 第二章:2.8 通过Django 在web页面上面输出 “Hello word ”
- 【ES】学习11-多桶排序
- JavaWeb开发如何用Tomcat部署发布
- hdu4289 Control 最大流最小割
- (原创)一个简洁通用的调用DLL函数的帮助类
- 从Web抓取信息的几个常用方法
- SQL中注意数据类型对性能的影响
- Nginx入门篇(六)之反向代理和负载均衡
- 关于 拼接 url 连接 参数的问题(爬虫)。
- orcl 对table的一些操作
热门文章
- nginx的安装和配置
- LFS(Linux From Scratch)构建过程全记录(七):进入Chroot并构建临时工具
- 华南理工大学 Python第4章课后小测-2
- VMware Component Manager服务无法启动
- 在Windows客户端自动设置AD用户头像
- Nginx服务器性能优化与安全配置实践指南
- 使用kubeoperator安装的k8s集群配置Ingress规则有关说明
- 查看docker容器占用的内存
- 11. Fluentd部署:性能优化
- 谣言检测——(PSA)《Probing Spurious Correlations in Popular Event-Based Rumor Detection Benchmarks》