Study with me in linux 6

Source: Internet
Author: User
I want to learn about linux 6 together-Linux Enterprise Application-Linux server application. The following is a detailed description. Lesson 5 for linux
1. Have vsftpd servers, http://www.linuxdiyf.com/bbs/viewthread.php? Tid = 53105 is set up. We 'd better restart the server to see if there is a chance to automatically enable vsftp.
2. by default, the previously installed server will create a vsftpd daemon under [root @ zy root] # ls/usr/local/sbin, also in [root @ zy root] # ls/etc/xinetd. d/vsftpd also has a vsftpd STARTUP script, so the server can be started in two ways, but we want it to run independently, so we need to disable this startup, [root @ zy root] # chkconfig -- list vsftpd
[Root @ zy root] # chkconfig vsftpd off
[Root @ zy root] # chkconfig -- list vsftpd
[Root @ zy root] # netstat-tnl check whether port 21 is occupied. If it is occupied, the process will be killed.
[Root @ zy root] # ps-aux | grep ftp
[Root @ zy root] # kill-9 process pid Number
[Root @ zy root] #/etc/rc. local run the sbin command under rc. local
[Root @ zy root] # view the port again in netstat-tnl
3. [root @ zy root] # vi/etc/vsftpd. conf modify the server configuration file
First, let's explain several common commands in vsftpd. conf configuration.
Anonymous_enable = YES: Allow Anonymous Users to comment out and remove it #
Local_enable = YES allow local users to log on and remove #
Write_enable = YES: allow local users to write data to remove #
Local_umask = 022 remove the umask value of the new local user file #
Abon_upload_enable = YES allows anonymous users to delete uploaded files #
Anon_mkdir_write_enable = YES: allows anonymous users to create directories.
Dirmessage_enable = YES. directory information can be removed #
Ftpd_banner = welcome to zy ftp server login welcome word removed #
Ls_recurse_enable = YES allows the client to use the ls-r command
Listen = YES listening mode add this sentence wq at the end to save and quit
[Root @ zy root] # killall-9 vsftpd our server runs independently and we need to kill it.
[Root @ zy root] #/usr/local/sbin/vsftpd & restart vsftpd
[Root @ zy root] # useradd redhat create a user
[Root @ zy root] # Set password for passwd redhat
[Root @ zy root] # log on to your ftp server through ftp 192.168.1.144
Enter the redhat password.
Ftp> pwd to view the current directory/home/redhat
Ftp> help view all available commands
Ftp> put/etc/services ftpservices: Upload/etc/services to the ftp server.
Ftp> ls view the directory of the ftp server
Ftp> quit exit ftp Server
Next, let's try uploading an article with an anonymous user. The key cause of the failure is/var/ftp, which does not belong to anonymous users.
[Root @ zy root] # cd/var/ftp/
[Root @ zy ftp] # mkdir/var/ftp/shangchuan create a new directory
[Root @ zy ftp] # chmod g + w shangchuan/make the Group Writable
[Root @ zy root] # chgrp ftp shangchuan/hand over the directory to the group ftp
In this way, you can use anonymous users to create directories.
Ftp> cd shangchuan to enter the upload directory
Then you can upload the article.
Then let's try another security of vsftp and lock the user directory.
First, we use the redhat user to log on to ftp
Ftp> pwd current directory/home/redhat
Ftp> cd/etc
OK to exit ftp quit
Then modify [root @ zy root] # vi/etc/vsftpd. conf
Set chroot_list_enable = YES
Chroot_list_file =/etc/vsftpd. chroot_list comment out the two lines
[Root @ zy root] # vi/etc/vsftpd. chroot_list
Redhat writes the user name into, wq
Then we log on to the ftp server again.
Log On with the redhat user this time
Ftp> pwd: The/directory is actually the user's locked directory.
Ftp> cd/etc will display a prompt indicating a failed change to the directory.
4. If we want to control user access to the ftp server
[Root @ zy root] # vi/etc/ftpuesrs
Redhat
Zy
Wq is saved and exited. By default, the two users redhat and zy cannot access the ftp server. etc/ftpuesrs is the blacklist of an ftp server.
We just successfully logged on with redhat. Now we add redhat to ftpusers.
[Root @ zy root] # echo "redhat">/etc/ftpusers
If you log on again, you will find that the logon fails.
[Root @ zy root] # vi/etc/passwd is sensitive to system users, that is, persons with uid less than 500 under the passwd directory are generally retained by the system, we should add them to/etc/ftpusers, which is very troublesome.
However, in turn, we can allow only designated persons to access the ftp server, while others are denied.
[Root @ zy root] # cp RedHat/vsftpd. pam/etc/pam. d/ftp
[Root @ zy root] # more/etc/pam. d/ftp users are controlled by the pam. d file.
We only need to change the pam. d/ftp file.
[Root @ zy root] # vi/etc/pam. d/ftp Replace the default denied command sense = deny with sense = allow so that only redhat and zy users can log on to the ftp server.
5. For the sake of security, we do not want the ftp user to be a system user, so we need to establish a virtual ftp user to ensure that the system does not have users, such as tom
First, edit users.txt, [root @ zy root] # vi users.txt
Enter user tom
Password 123 user and password do not enter, the first line is the user tom, the second line is the password 123
[Root @ zy root] # id tom: check if the tom user does not exist.
[Root @ zy root] # db_load-T-t hash-f users.txt/etc/vsftpd_login.db to explain-T is the command to write a simple txt file into the db database-t is written type: hash, -f indicates the file name, and/etc/vsftpd_login.db indicates the location where the file is written.
[Root @ zy root] # chmod 600/etc/vsftpd_login.db change the permission of this file to 600
[Root @ zy root] # vi/etc/pam. d/ftp modify the pam. d service file
First, we need to comment out the previous one and add # comment out before all.
Then let's add a few more words.
Auth required pam_userdb.so db =/etc/vsftpd_login.db
Account required pam_userdb.so db =/etc/vsftpd_login.db
Auth is authentication, and required is a control method. We use the pam_user.db.so module and load a db =/etc/vsftpd_login.db
The account type is
[Root @ zy root] # useradd vuser creates a virtual account for ing. This user does not need to set a password.
[Root @ zy root] # vi/etc/vsftpd. conf edit Server Configuration
We want to disable all commands starting with anon, prohibit anonymous users from logging on and then
We need to add two Commands: guest_enable = YES
Guest_username = vuser
Wq save and exit
Then, in the experiment, we use redhat to log on and the response is logon Failure de.
Ftp> user we use virtual user to log on
(Username) tom
Enter Password 123
OK
Let's take a look at the next file. get. bashrc is successfully downloaded. ls, but we cannot see quit.
[Root @ zy root] # cp install. log/home/vuser/copy install. log
[Root @ zy root] # chmod o + r/home/vuser/change the directory to be readable by others
We can see install. log On from tom again.
Note that each modification to the/etc/vsftpd. conf file must be initiated again. This command can be used to replace [root @ zy root] # killall-HUP vsftpd
It's not easy for me, guys. I typed it for half a day. When you learned a little bit of knowledge, my buddy gave me some support. I will continue to work hard to finish it together for linux.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.