In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to create and configure virtual users under the CentOS system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to create and configure virtual users under the CentOS system.
Download the latest version of the current vsftp
The code is as follows:
Wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.3.4.tar.gz
Second, prepare before installation
1. Create a local user wwwftp for virtual user mapping
The code is as follows:
Useradd wwwftp-d / data/www-s / sbin/nologin
2. Create a custom configuration directory
The code is as follows:
Mkdir-p / data/soft/vsftpd/conf
Mkdir-p / data/soft/vsftpd/bin
Mkdir-p / data/soft/vsftpd/lib
Mkdir-p / data/soft/vsftpd/user_conf
Mkdir-p / data/soft/vsftpd/empty
Mkdir-p / data/soft/vsftpd/logs
Mkdir-p / data/www
Mkdir-p / data/www/user1
Mkdir-p / data/www/user2
3. Set permissions for custom directories
The code is as follows:
Chown-R wwwftp:www / data/www
Chmod-R 700 / data/soft/vsftpd/empty/
Chown-R wwwftp:wwwftp / data/soft/vsftpd/empty/
4. Copy the library files used to verify user login to a custom directory for easy management
The code is as follows:
Cp / lib/security/pam_userdb.so / data/soft/vsftpd/lib/
5. Install the required software
The code is as follows:
Yum-y install gcc db4* pam*
Third, decompress and install vsftpd
The code is as follows:
Tar zxvf vsftpd-2.3.4.tar.gz
Cd vsftpd-2.3.4
Tcp_wrappers and ssl are not supported by source code installation by default
Builddefs.h needs to be modified
The code is as follows:
/ * the default values are as follows: * /
# undef VSF_BUILD_TCPWRAPPERS / * whether TCPWRAPPERS is supported * /
# define VSF_BUILD_PAM / * whether custom virtual user login is supported * /
# undef VSF_BUILD_SSL / * whether SSL transfer is supported * /
/ * set the corresponding item to define, otherwise set it to undef*/
Compile vsftpd
The code is as follows:
Make
Check to see if the compiled vsftpd binaries have pam loaded
The code is as follows:
Ldd vsftpd
As follows:
The code is as follows:
[root@CentOS5 vsftpd-2.3.4] # ldd vsftpd
Linux-gate.so.1 = > (0x00628000)
Libwrap.so.0 = > / lib/libwrap.so.0 (0x00cee000)
Libnsl.so.1 = > / lib/libnsl.so.1 (0x0015f000)
Libpam.so.0 = > / lib/libpam.so.0 (0x00fc4000)
Libdl.so.2 = > / lib/libdl.so.2 (0x007dc000)
Libresolv.so.2 = > / lib/libresolv.so.2 (0x008d8000)
Libutil.so.1 = > / lib/libutil.so.1 (0x00110000)
Libcap.so.1 = > / lib/libcap.so.1 (0x00d99000)
Libc.so.6 = > / lib/libc.so.6 (0x0029a000)
Libaudit.so.0 = > / lib/libaudit.so.0 (0x00114000)
/ lib/ld-linux.so.2 (0x004a2000)
Seeing libpam.so.0 = > / lib/libpam.so.0 (0x00fc4000) indicates that the pam authentication module has been loaded successfully
The code is as follows:
Cp vsftpd/ data/soft/vsftpd/bin
4. Configure vsftpd
1. Create a master configuration file
The code is as follows:
Vi / data/soft/vsftpd/conf/vsftpd.conf
As follows:
The code is as follows:
Local_enable=YES
Anonymous_enable=NO
Anon_upload_enable=NO
Anon_other_write_enable=NO
Anon_mkdir_write_enable=NO
Ftpd_banner=Welcome to FTP service.
Listen=YES
Listen_port=21
Connect_from_port_20=YES
Nopriv_user=nobody
Tcp_wrappers=YES
Chroot_local_user=NO
Chroot_list_enable=YES
Chroot_list_file=/data/soft/vsftpd/chroot_list
Userlist_enable=yes
Userlist_deny=no
Userlist_file=/data/soft/vsftpd/allow
Dual_log_enable=YES
Vsftpd_log_file=/data/soft/vsftpd/logs/vsftpd.log
Xferlog_enable=YES
Xferlog_file=/data/soft/vsftpd/logs/xferlog
Pasv_enable=YES
Pasv_min_port=50000
Pasv_max_port=60000
Guest_enable=YES
Guest_username=wwwftp
Pam_service_name=vsftpd
Virtual_use_local_privs=YES
Use_localtime=YES
User_config_dir=/data/soft/vsftpd/user_conf
Secure_chroot_dir=/data/soft/vsftpd/empty
2. Create a user file that allows login to ftp.
The code is as follows:
Vi / data/soft/vsftpd/allow
As follows:
The code is as follows:
User1
User2
3. Create a user list file to lock the user directory
The code is as follows:
Vi / data/soft/vsftpd/chroot_list
As follows
The code is as follows:
User1
User2
4. Configure the pam authentication module of vsftpd (for virtual user authentication)
The code is as follows:
Vi / etc/pam.d/vsftpd
As follows
The code is as follows:
Auth required / data/soft/vsftpd/lib/pam_userdb.so db=/data/soft/vsftpd/login
Account required / data/soft/vsftpd/lib/pam_userdb.so db=/data/soft/vsftpd/login
Save exit
5. Create a user name and password text file
The code is as follows:
Vi / data/soft/vsftpd/login.txt
As follows: one line user name, one line password
The code is as follows:
User1
123456
User2
654321
Save exit
6. Use db_load to generate user database
The code is as follows:
Db_load-T-t hash-f / data/soft/vsftpd/login.txt / data/soft/vsftpd/login.db
Chmod 600 / data/soft/vsftpd/login.db
Rm-rf / data/soft/vsftpd/login.txt
7. Configure virtual user customized configuration files
The code is as follows:
Vi / data/soft/vsftpd/user_conf/user1
User1 all permissions
The code is as follows:
Local_root=/data/www/user1
Write_enable=YES
Local_umask=022
Save exit
The code is as follows:
Vi / data/soft/vsftpd/user_conf/user2
User2 only allows downloads
The code is as follows:
Local_root=/data/www/user2
Write_enable=NO
Download_enable=YES
Local_umask=022
Save exit
8. Start the vsftpd service
The code is as follows:
/ data/soft/vsftpd/bin/vsftpd / data/soft/vsftpd/conf/vsftpd.conf &
5. Testing
User1 login can read, write, delete, create, and modify all permissions
User2 login only has download permission
At this point, I believe you have a deeper understanding of "how to create and configure virtual users under the CentOS system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.