当先锋百科网

首页 1 2 3 4 5 6 7

ftp虚拟用户实验报告
实验环境:一台CentOS7系统的服务器,一台客户机用作验证(windows、linux都可)
实验要求: 使用CentOS7搭建FTP服务器。
实验步骤:
服务端搭建
[root@localhost ~]# vim /etc/selinux/config

This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=disabled
SELINUXTYPE= can take one of three two values:
targeted - Targeted processes are protected,
minimum - Modification of targeted policy. Only selected processes are protected.
mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@localhost ~]# reboot
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# yum -y install vsftpd ftp
[root@localhost ~]# cd /etc/vsftpd/
[root@localhost vsftpd]# vim vuser.list
ccx
123
ccx1
123
[root@localhost vsftpd]# db_load -T -t hash -f vuser.list vuser.db
root@localhost vsftpd]# file vuser.db
vuser.db: Berkeley DB (Hash, version 9, native byte-order)
[root@localhost vsftpd]# cd /etc/pam.d/
[root@localhost pam.d]# cp vsftpd vsftpd.bak
[root@localhost pam.d]# vim vsftpd
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd/vuser
account required pam_userdb.so db=/etc/vsftpd/vuser
[root@localhost vsftpd]# cd /etc/vsftpd/
[root@localhost vsftpd]# useradd -d /var/ftproot -s /sbin/nologin ccx
[root@localhost vsftpd]# vim vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
allow_writeable_chroot=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
guest_enable=YES
guest_username=cx
user_config_dir=/etc/vsftpd/users
tcp_wrappers=YES
[root@localhost vsftpd]# mkdir users
[root@localhost vsftpd]# cd users/
[root@localhost users]# vim ccx
anon_upload_enable=YES
anon_mkdir_write_enable=YES
[root@localhost users]# touch ccx1
[root@localhost users]# chmod 777 /var/ftproot/
[root@localhost users]# systemctl stop firewalld
[root@localhost users]# systemctl restart vsftpd
客户端验证
为了方便验证
[root@localhost ~]# touch {1…10}.txt
[root@localhost ~]# cd /var/ftproot/
[root@localhost ftproot]# touch {a…d}.txt
[root@localhost ~]# ftp 192.168.1.100
Connected to 192.168.1.100 (192.168.1.100).
220 (vsFTPd 3.0.2)
Name (192.168.1.100:root): ccx
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,1,100,151,99).
150 Here comes the directory listing.
-rw-r–r-- 1 0 0 0 Dec 13 10:37 a.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 b.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 c.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 d.txt
226 Directory send OK.
ftp> put 1.txt
local: 1.txt remote: 1.txt
227 Entering Passive Mode (192,168,1,100,135,120).
150 Ok to send data.
226 Transfer complete.
ftp> ls
227 Entering Passive Mode (192,168,1,100,137,82).
150 Here comes the directory listing.
-rw-r–r-- 1 1001 1001 0 Dec 13 10:41 1.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 a.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 b.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 c.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 d.txt
226 Directory send OK.
ftp> get a.txt
local: a.txt remote: a.txt
227 Entering Passive Mode (192,168,1,100,32,209).
150 Opening BINARY mode data connection for a.txt (0 bytes).
226 Transfer complete.
[root@localhost ~]# ftp 192.168.1.100
Connected to 192.168.1.100 (192.168.1.100).
220 (vsFTPd 3.0.2)
Name (192.168.1.100:root): ccx1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,1,100,180,116).
150 Here comes the directory listing.
-rw-r–r-- 1 1001 1001 0 Dec 13 10:41 1.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 a.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 b.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 c.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 d.txt
226 Directory send OK.
ftp> get b.txt
local: b.txt remote: b.txt
227 Entering Passive Mode (192,168,1,100,236,56).
150 Opening BINARY mode data connection for b.txt (0 bytes).
226 Transfer complete.
ftp> put 2.txt
local: 2.txt remote: 2.txt
227 Entering Passive Mode (192,168,1,100,179,194).
550 Permission denied.
ftp> ls
227 Entering Passive Mode (192,168,1,100,60,202).
150 Here comes the directory listing.
-rw-r–r-- 1 1001 1001 0 Dec 13 10:41 1.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 a.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 b.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 c.txt
-rw-r–r-- 1 0 0 0 Dec 13 10:37 d.txt
226 Directory send OK.
[root@localhost ~]# ls
10.txt 2.txt 4.txt 6.txt 8.txt anaconda-ks.cfg b.txt
1.txt 3.txt 5.txt 7.txt 9.txt a.txt