Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install VSFTPD in linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to install VSFTPD in linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First install rpm-ivh vsftpd-2.2.2-11.el6.x86_64.rpm

After installation, you need to modify the configuration parameters

# Allow anonymous FTP? (Beware-allowed by default if you comment this out)

# anonymous_enable=YES

Anonymous_enable=NO

Set not to allow anonymous access

#

# Uncomment this to allow local users to log in.

Local_enable=YES

Make it accessible to local users. Note: mainly for virtual host users, if the project is set to NO, then all virtual users will not be able to access it.

#

# Uncomment this to enable any form of FTP write command.

Write_enable=YES

Set to be able to write.

#

# Default umask for local users is 077. You may wish to change this to 022

# if your users expect that (022 is used by most other ftpd's)

Local_umask=022

Set the permission mask for the uploaded file.

#

# Uncomment this to allow the anonymous FTP user to upload files. This only

# has an effect if the above global write enable is activated. Also, you will

# obviously need to create a directory writable by the FTP user.

# anon_upload_enable=YES

Anon_upload_enable=NO

Anonymous users are prohibited from uploading.

#

# Uncomment this if you want the anonymous FTP user to be able to create

# new directories.

# anon_mkdir_write_enable=YES

Anon_mkdir_write_enable=NO

Anonymous users are prohibited from creating directories.

#

# Activate directory messages-messages given to remote users when they

# go into a certain directory.

Dirmessage_enable=YES

Set to enable the directory slogan function.

#

# Activate logging of uploads/downloads.

Xferlog_enable=YES

Set to turn on logging.

#

# Make sure PORT transfer connections originate from port 20 (ftp-data).

Connect_from_port_20=YES

Set port 20 for data connection.

#

# If you want, you can arrange for uploaded anonymous files to be owned by

# a different user. Note! Using "root" for uploaded files is not

# recommended!

# chown_uploads=YES

Chown_uploads=NO

Set to prohibit the upload of files to change the host.

# chown_username=whoever

#

# You may override where the log file goes if you like. The default is shown

# below.

Xferlog_file=/var/log/vsftpd.log

Set the service log save path for Vsftpd. Note that the file does not exist by default. It is necessary to manually touch out, and because the service host user of the Vsftpd has been changed here is the manually established Vsftpd. Care must be taken to give the user write permissions to the log, otherwise the service will fail to start.

#

# If you want, you can have your log file in standard ftpd xferlog format

Xferlog_std_format=YES

Set the log to use a standard record format.

#

# You may change the default value for timing out an idle session.

# idle_session_timeout=600

Set the idle connection timeout. The default is used here. Leave the specific value to each specific user to specify, of course, if not specified, or use the default value of 600 here, in seconds.

#

# You may change the default value for timing out a data connection.

# data_connection_timeout=120

Set the maximum continuous transmission time at a time. The default is used here. Leave the specific value to each specific user to specify, of course, if not specified, or use the default value of 120 here, in seconds.

#

# It is recommended that you define on your system a unique user which the

# ftp server can use as a totally isolated and unprivileged user.

# nopriv_user=ftpsecure

Nopriv_user=vsftpd

Set the host user of the supporting Vsftpd service to be a manually established Vsftpd user. Note that once a change is made to the host user, attention must be paid to the read and write authorization of the read and write files associated with the service. For example, the log file must give the user write permission and so on.

#

# Enable this and the server will recognise asynchronous ABOR requests. Not

# recommended for security (the code is non-trivial). Not enabling it

# however, may confuse older FTP clients.

Async_abor_enable=YES

Set to support asynchronous transmission.

#

# By default the server will pretend to allow ASCII mode but in fact ignore

# the request. Turn on the below options to have the server actually do ASCII

# mangling on files when in ASCII mode.

# Beware that on some FTP servers, ASCII support allows a denial of service

# attack (DoS) via the command "SIZE / big/file" in ASCII mode. Vsftpd

# predicted this attack and has always been safe, reporting the size of the

# raw file.

# ASCII mangling is a horrible feature of the protocol.

Ascii_upload_enable=YES

Ascii_download_enable=YES

Set the upload and download functions that support ASCII mode.

#

# You may fully customise the login banner string:

Ftpd_banner=This Vsftp server supports virtual users ^ _ ^

Set the login slogan for Vsftpd.

#

# You may specify a file of disallowed anonymous e-mail addresses. Apparently

# useful for combatting certain DoS attacks.

# deny_email_enable=YES

# (default follows)

# banned_email_file=/etc/vsftpd/banned_emails

#

# You may specify an explicit list of local users to chroot () to their home

# directory. If chroot_local_user is YES, then this list becomes a list of

# users to NOT chroot ().

# chroot_list_enable=YES

Chroot_list_enable=NO

Users are not allowed to log out of their FTP home directory.

# (default follows)

# chroot_list_file=/etc/vsftpd/chroot_list

#

# You may activate the "- R" option to the builtin ls. This is disabled by

# default to avoid remote users being able to cause excessive I/O on large

# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume

# the presence of the "- R" option, so there is a strong case for enabling it.

# ls_recurse_enable=YES

Ls_recurse_enable=NO

Prohibit users from using the "ls-R" command after logging in to FTP. This command can cause significant overhead on server performance. If this item is allowed, blocking multiple users using the command at the same time will pose a threat to the server.

# When "listen" directive is enabled, vsftpd runs in standalone mode and

# listens on IPv4 sockets. This directive cannot be used in conjunction

# with the listen_ipv6 directive.

Listen=YES

Set the Vsftpd service to work in StandAlone mode. By the way, the so-called StandAlone mode is that the service has its own daemon support, and we will be able to see the daemon name of vsftpd under the ps-A command. If you do not want to work in StandAlone mode, you can choose SuperDaemon mode, in which vsftpd will not have its own daemon, but will be fully represented by the super daemon Xinetd, at the same time, many functions of Vsftp services will not be implemented.

#

# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6

# sockets, you must run two copies of vsftpd whith two configuration files.

# Make sure, that one of the listen options is commented!!

# listen_ipv6=YESpam_service_name=vsftpd

Set the authentication profile name of the Vsftpd under the PAM service. Therefore, PAM verification will refer to the vsftpd file configuration under / etc/pam.d/.

Userlist_enable=YES

Set that users in userlist_file will not be allowed to use FTP.

Tcp_wrappers=YES

Set to support TCP Wrappers. # KC: The following entries are added for supporting virtual ftp users.

The following are important configuration items for Vsftpd virtual user support. These settings are not included in the default Vsftpd.conf, so you need to add your own configuration manually. Guest_enable=YES

Set to enable the virtual user feature.

Guest_username=overlord

Specifies the host user for the virtual user.

Virtual_use_local_privs=YES

Set the permissions of virtual users in line with their host users.

User_config_dir=/etc/vsftpd/vconf

Set the configuration file storage path of the virtual user's personal Vsftp. In other words, each Vsftp virtual user's personality profile will be stored in this specified directory, and one thing to note is that these profile names must be the same as the virtual user name.

Save exit.

3. Establish the log file of Vsftpd, and change the owner to the service host user of Vsftpd:

[root@KcentOS5 ~] # touch / var/log/vsftpd.log

[root@KcentOS5] # chown vsftpd.vsftpd / var/log/vsftpd.log 4. Establish a virtual user profile storage path:

[root@KcentOS5 ~] # mkdir / etc/vsftpd/vconf/

three。 Create a virtual user database file

1. First, create a virtual user list file:

[root@KcentOS5 ~] # touch / etc/vsftpd/virtusers

A virtual user list file is created, which is a data file to record the username and password of the vsftpd virtual user. I name it virtusers here. To avoid file clutter, I put the list file under / etc/vsftpd/.

two。 Edit the virtual user list file:

[root@KcentOS5 ~] # vi / etc/vsftpd/virtusers

-

Kanecruise

123456

Near

123456near

Mello

123456mello

-

Edit the virtual user list file and add the user name and password information to it. The format is simple: "one user name, one password".

3. Generate a virtual user data file:

[root@KcentOS5] # db_load-T-t hash-f / etc/vsftpd/virtusers / etc/vsftpd/virtusers.db

Here, by the way, let me briefly explain this order.

See how db4's db_load command is used:

[root@KSRV2 vsftpd] # db_load

Usage: db_load [- nTV] [- c name=value] [- f file]

[- h home] [- P password] [- t btree | hash | recno | queue] db_file

Usage: db_load-r lsn | fileid [- h home] [- P password] db_file

Explain that in this article, the db_load command has several related options, especially the argument-T

The-T option allows non-Berkeley DB applications to easily load text files into databases.

If the database to be created is of type Btree or Hash, or the keyword keys is specified as set, the input must be paired lines of text, where the first line of the pair is the key item, and the second line of the pair is its corresponding data item. If the database to be created is of type Queue or Recno and the keywork keys is not set, the input must be lines of text, where each line is a new data item for the database.

Option-T allows the application to load the translation of text files into the database. Since we then store the virtual user's information in a file, we must use this option in order for the Vsftpd application to load user data through text. If the-T option is specified, the underlying access method type must be specified using the-t option.

If the option-T is specified, be sure to follow the suboption-tmurt

Specify the underlying access method. If no-t option is specified, the database will be loaded into a database of the same type as was dumped; for example, a Hash database will be created if a Hash database was dumped.

Btree and Hash databases may be converted from one to the other. Queue and Recno databases may be converted from one to the other. If the-k option was specified on the call to db_dump then Queue and Recno databases may be converted to Btree or Hash, with the key being the integer record number.

The sub-option-t, appended after the-T option, is used to specify the type of database to be loaded by translation. Under the extension introduction,-t can specify data types such as Btree, Hash, Queue, and Recon databases. Here, the next thing we need to specify is the hash type.

4. View the generated virtual user data file

[root@KcentOS5 ~] # ll / etc/vsftpd/virtusers.db

-rw-r--r-- 1 root root 12288 Sep 16 03:51 / etc/vsftpd/virtusers.db

It is important to note that when you want to add a virtual user later, you only need to add the new user name and password to the virtual user list file in the format of "one-line username, one-line password". But this is not enough, it will not take effect! Also execute the "db_load-T-t hash-f virtual user list file virtual user database file. Db" command to make it effective!

four。 Set the PAM authentication file and specify the virtual user database file to read

1. Look at the PAM authentication configuration file of the original Vsftp:

[root@KcentOS5 ~] # cat / etc/pam.d/vsftpd

#% PAM-1.0

Session optional pam_keyinit.so force revoke

Auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed

Auth required pam_shells.so

Auth include system-auth

Account include system-auth

Session include system-auth

Session required pam_loginuid.so

two。 Make a backup before editing:

[root@KcentOS5] # cp / etc/pam.d/vsftpd / etc/pam.d/vsftpd.backup3. Edit the PAM authentication profile for Vsftpd

[root@KcentOS5 ~] # vi / etc/pam.d/vsftpd

#% PAM-1.0

Auth sufficient / lib/security/pam_userdb.so db=/etc/vsftpd/virtusers

Account sufficient / lib/security/pam_userdb.so db=/etc/vsftpd/virtusers

The above two items are added manually to verify the security and account permissions of the virtual user.

Auth here refers to the authentication of the user's username and password.

In this case, accout refers to validating the permissions and restrictions on the user's account.

2 items manually added in vi / etc/pam.d/vsftpd

Auth sufficient / lib/security/pam_userdb.so db=/etc/vsftpd/virtusers

Account sufficient / lib/security/pam_userdb.so db=/etc/vsftpd/virtusers

If it's 64-bit

Need to be changed to:

Auth sufficient / lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers

Account sufficient / lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers

The following sufficient indicates the sufficient condition, that is, once the verification is passed here, you do not have to go through the remaining verification steps below. On the contrary, if it does not pass, it will not be immediately blocked by the system, because the failure of sufficient does not determine the failure of the entire verification, which means that the user will have to go through the rest of the verification audit.

The following / lib/security/pam_userdb.so indicates that the audit will be carried out by calling the library function pam_userdb.so.

The final db=/etc/vsftpd/virtusers specifies that the verification library function will call the data in the specified database for validation.

# KC: The entries for Vsftpd-PAM are added above.session optional pam_keyinit.so force revoke

Auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed

Auth required pam_shells.so

Auth include system-auth

Account include system-auth

Session include system-auth

Session required pam_loginuid.so

five。 Configuration of virtual users

1. Plan the main path for the virtual user:

[root@KcentOS5 ~] # mkdir / opt/vsftp/

two。 Set up the FTP user directory for the test user:

[root@KcentOS5 ~] # mkdir / opt/vsftp/kanecruise/ / opt/vsftp/mello/ / opt/vsftp/near/

3. Create a virtual user profile template: [root@KcentOS5 ~] # cp / etc/vsftpd/vsftpd.conf.backup / etc/vsftpd/vconf/vconf.tmp

4. Customize the virtual user template profile:

[root@KcentOS5 ~] # vi / etc/vsftpd/vconf/vconf.tmp

-

Local_root=/opt/vsftp/virtuser

Specify the specific primary path of the virtual user.

Anonymous_enable=NO

Set not to allow anonymous users to access.

Write_enable=YES

Set to allow write operations.

Local_umask=022

Set the permission mask for uploading files.

Anon_upload_enable=NO

Anonymous users are not allowed to upload.

Anon_mkdir_write_enable=NO

The setting does not allow anonymous users to establish directories.

Idle_session_timeout=600

Sets the idle connection timeout.

Data_connection_timeout=120

Set the maximum time for a single continuous transmission.

Max_clients=10

Sets the number of concurrent client accesses.

Max_per_ip=5

Set the maximum number of threads for a single client, this configuration is mainly to take care of Flashget, Thunderbolt and other multi-threaded download software.

Local_max_rate=50000

Set the maximum transmission rate of the user, in bUniver s.

-

Here, the original vsftpd.conf configuration file is simplified and saved as a template for the virtual user profile. There will not be much configuration content to be specified here, and the main framework and restrictions will be defined by Vsftpd's main configuration file vsftpd.conf, that is, configuration items not mentioned in the virtual user profile will refer to the settings in the master configuration file. Here, as a virtual user's profile template, you only need to leave some configuration items with user flow control and access mode control. The key item here is the local_root configuration, which is used to specify the FTP primary path of the virtual user. 5. Change the owner of the virtual user's home directory to the virtual host user:

[root@KcentOS5] # chown-R overlord.overlord / opt/vsftp/6. Check permissions:

[root@KcentOS5 ~] # ll / opt/vsftp/

Total 24

Drwxr-xr-x 2 overlord overlord 4096 Sep 16 05:14 kanecruise

Drwxr-xr-x 2 overlord overlord 4096 Sep 16 05:00 mello

Drwxr-xr-x 2 overlord overlord 4096 Sep 16 05:00 near

six。 Customize for test users:

1. Copy from the virtual user template profile:

[root@KcentOS5 ~] # cp / etc/vsftpd/vconf/vconf.tmp / etc/vsftpd/vconf/kanecruise

two。 Customize for specific users:

[root@KcentOS5 ~] # vi / etc/vsftpd/vconf/kanecruise

-

Local_root=/opt/vsftp/kanecruise

Anonymous_enable=NO

Write_enable=YES

Local_umask=022

Anon_upload_enable=NO

Anon_mkdir_write_enable=NO

Idle_session_timeout=300

Data_connection_timeout=90

Max_clients=1

Max_per_ip=1

Local_max_rate=25000

-

seven。 Start the service:

[root@KcentOS5 ~] # service vsftpd start

Starting vsftpd for vsftpd: [OK]

eight。 Test:

1. Pre-place files in the virtual user directory:

[root@KcentOS5 ~] # touch / opt/vsftp/kanecruise/kc.test

two。 Log in to FTP as a client from another machine:

[root@Yum ~] # ftp

Ftp > open 192.168.1.22

Connected to 192.168.1.22.

220 This Vsftp server supports virtual users ^ _ ^

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (192.168.1.22:root): kanecruise

331 Please specify the password.

Password: 123456

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

3. Test order operation

Ftp > ls

227 Entering Passive Mode (192, 168, 1, 22, 220, 24)

150 Here comes the directory listing.

-rw-r--r-- 1 501 501 0 Sep 15 21:14 kc.test

226 Directory send OK. (catalog list successful)

This is the end of "how linux installs VSFTPD". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report