FTP服务
1.匿名用户权限设置
更改配置文件
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
anon_root=/opt
anon_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
更新
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
重启
[root@localhost ~]# systemctl restart vsftpd
开启ftp服务器
[root@localhost ~]# systemctl start vsftpd
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
关闭安全性功能
[root@localhost ~]# setenforce 0
查看端口
[root@localhost ~]# netstat -ntpl
在opt下创一个aaa的目录
[root@localhost ~]# cd /opt
[root@localhost opt]# mkdir /aaa
[root@localhost opt]# ll
total 2
drwxr-xr-x. 2 root root 33 Nov 10 04:44 aaa
dr-xr-xr-x. 8 root root 2048 Dec 9 2015 cdrom
drwxr-xr-x. 2 root root 6 Nov 10 04:01 media
drwxr-xr-x. 2 root root 18 Nov 10 03:40 test
给aaa改权限
[root@localhost opt]# chmod 777 aaa
[root@localhost opt]# ll
total 2
drwxrwxrwx. 2 root root 33 Nov 10 04:44 aaa
dr-xr-xr-x. 8 root root 2048 Dec 9 2015 cdrom
drwxr-xr-x. 2 root root 6 Nov 10 04:01 media
drwxr-xr-x. 2 root root 18 Nov 10 03:40 test
2.端口
listens on IPv4 sockets. This directive cannot be used in conjunction
with the listen_ipv6 directive.
listen=YES
listen_address=192.168.200.20
listen_port=21
pam_service_name=vsftpd
This directive enables listening on IPv6 sockets. By default, listening
重启
[root@localhost ~]# systemctl restart vsftpd
确认服务是否存在可以查看端口或状态
[root@localhost ~]# netstat -ntpl | grep vsftpd
tcp 0 0 192.168.200.20:21 0.0.0.0:* LISTEN 66889/vsftpd
[root@localhost ~]# systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-11-12 02:11:07 EST; 1min 0s ago
Process: 66888 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 66889 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─66889 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Nov 12 02:11:07 localhost.localdomain systemd[1]: Starting Vsft…
Nov 12 02:11:07 localhost.localdomain systemd[1]: Started Vsftp…
Hint: Some lines were ellipsized, use -l to show in full.
3.限制访问用户:
1.创立一个用户并设置密码
[root@localhost ~]# useradd -s /sbin/nologin -g ftp test
[root@localhost ~]# passwd test
Changing password for user test.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
2.修改配置文件( vi /etc/vsftpd/vsftpd.conf)
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
Ctrl+GG最后一行添加
pam_service_name=vsftpd
userlist_enable=NO
userlist_deny=YES
userlist_file=/etc/vsftpd/user_list
tcp_wrappers=YES
在/etc/vsftpd/chroot_list填一个test的用户
查看一下
[root@localhost ~]# cd /etc
[root@localhost etc]# cd vsftpd
[root@localhost vsftpd]# ls
chroot_list user_list vsftpd_conf_migrate.sh
ftpusers vsftpd.conf
[root@localhost vsftpd]# vi 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
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
test
~
~
恢复一下
[root@localhost vsftpd]# vi user_list
把test删了
ftp文件夹未错误