Linux FTP anonymous, local, virtual user service construction

1. smdb: TCP port 139 (SMB protocol), 445 port (CIFS protocol)
2. nmbd: UDP port 137-138 (NetBIOS protocol)
3. mount -o: remote mount (need to install the samba4-libs package, cifs-utils Package)
4. FTP connection
*
Control connection TCP21, send FTP command
*
Data connection TCP20, used to upload and download data

5. FTP active passive mode
*
Active: the client opens the port and waits for the server to send data (tcp21 port, tcp20 port)
*
Passive: the server opens the port and waits for the client to send data (tcp20 port, an unknown advanced port)

6. FTP transfer mode
*
Text mode: ASCII, character encoding method, used for sending plain text files
*
Binary mode: (Binary mode) used to transfer text files and non-text files

7. C/S: Client Service B/S: Browser Service

8. FTP service is divided into three types
*
Anonymous user name: the user name is ftp or anonymous, and any password can be provided.
*
Local user (built-up sercer server): requires a user name and corresponding password, suitable for all users Is the person using this server.
*
Virtual users (for security reasons): Login authentication is performed through a separate user database file (mapping users created in the host).

9. The server side needs to install the vsftpd software, the system permissions and configuration file permissions must be turned on during setting, the service must be restarted after the configuration file is modified, and the firewall and selinux must be turned off.

10. Anonymous FTP service establishment
Key: Turn on system permissions and modify the configuration file
yum -y install vsftpd ftp
#Install the software rpm -ql vsftpd |less #Check if the
systemctl restart vsftpd is successfully installed
#Enable the vsftpd function netsat -anpt |grep 21 #test
Or open a browser or host computer or search for ftp in Linux: //192.168...test
ll /var/ftp/pub/ -d #View permissions or grep ftp /etc/passwd
chown ftp /var/ftp/pub #Set For the owner
rpm -qc vsftpd #View the configuration file
cd /etc/vsftpd #Switch directory
ls
#View cp vsftpd.conf{,.ori} #safe backup
vi vsftpd.conf
Insert picture description here
systemctl restart vsftpd #Restart the service
ll /var/ftp/ Pub
can create test file detection in the current directory

11. Local user FTP service establishment

useradd amber
useradd tom
#Create user echo “123” |passwd --stdin amber &> /dev/null
echo “123” |passwd --stdin amber &> /dev/null #Set password
tail -2 /etc/shadow # View
cd /etc/vsftpd #Switch directory
vim vsftpd.conf and
add allow_writeable_chroot=YES
systemctl start vsftpd #Open the service and
test independently

12. Blacklist

There are two blacklists in the /etc/vsftpd directory, namely ftpusers and user_list.
The priority of ftpusers is higher than user_list.
User_list can also be set as a whitelist, you need to modify the configuration file /etc/vsftpd/vsftpd.conf, and add userlist_deny=NO,
userlist_enable=YES.

13. Virtual FTP service construction

cd /etc/vsftpd
cp vsftpd.conf.ori vsftpd.conf
#If you have done other things before, you need to change back to the initial configuration file vim vusers.txt #Add users such as zhangsan 123 李四456…

file vuser.txt
db_load -T -t hash -f vusers.txt vusers.db
file vusers.db
chmod 600 vusers.*
useradd -d /var/ftproot -s /sbin/nologin vuser #The
above steps modify the file as the database in the blog format

cd /etc/pam.d
cp vsftpd vsftpd.vu
vim vsftpd.vu #The
Insert picture description here
above steps are for PAM authentication process configuration

vim vsftpd.conf
Insert picture description here
systemctl restart vsftpd #Restart the service
chmod 777 /var/ftproot
#Change permissions touch /var/ftproot/vuser.txt #Create a test file and enable anonymous permissions to upload files (add anno_other_write_enable in /etc/vsftpd.conf =YES)

14. Different configuration methods for different users in virtual FTP
cd /etc/vsftpd
mkdir vusers_dir
touch vusers_dir/{zhangsan,lisi,wangwu…}
vim vusers_dir /wangwu
write anon_upload_enable=YES
anon_mkdir_write_enable=YES anon_other_write_enable=YES anon_other_wang_write_enable=YES
anon_other_write_enable
=/ftp/ YES local_wu
mkdir /{zhangsan,lisi,wangwu...} /ftp/wangwu -p
chmod 777 /ftp/wangwu
touch /ftp/wangwu/wangwu.txt
vim vsftpd.conf
add
user_config_dir=/etc/vsftpd/vusers_dir

Guess you like

Origin blog.csdn.net/qq_39109226/article/details/109539618