Set up an FTP server in Linux (5)

Source: Internet
Author: User
Article Title: Set up an FTP server in Linux (5 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Configure the "/etc/ftphosts" File
The "/etc/ftphosts" file sets a rule for each user to allow the user to log on to the ftp server from a host or not allow the user to log on to the ftp server from a host.
Create the "ftphosts" file (touch/etc/ftphosts) and add the following lines:
# Example host access file
#
# Everything after a' # 'is treated as comment,
# Empty lines are ignored
Allow ftpadmin 208.164.186.1 208.164.186.2 208.164.186.4
Change the File Permission to 600:
[Root @ deep] # chmod 600/etc/ftphosts
Each row may be:
Allow <username> <addrglob>
Or
Deny <username> <addrglob>
"Allow" allows users to access the ftp server from the <addrglob> address using the <username> User Name. <Addrglob> can contain multiple addresses.
"Deny" prohibits <username> users from accessing the ftp server from the <addrglob> address. <Addrglob> can contain multiple addresses.
Configure the "/etc/ftpusers" File
The "/etc/ftpusers" file sets which users are not allowed to connect to the ftp server.
Create the "ftpusers" file (touch/etc/ftpusers) and add the following lines:
Root
Bin
Daemon
Adm
Lp
Sync
Shutdown
Halt
Mail
News
Uucp
Operator
Games
Nobody
Set the File Permission to 600:
[Root @ deep] # chmod 600/etc/ftpusers
Configure the "/etc/ftpconversions" File
"/Etc/ftpconversions" is used to control whether the file is compressed when it is transmitted.
Create the "ftpconversions" file (touch/etc/ftpconversions) and add the following to the file:
:. Z:/bin/compress-d-c % s: T_REG | T_ASCII: O_UNCOMPRESS: UNCOMPRESS
:::. Z:/bin/compress-c % s: T_REG: O_COMPRESS: COMPRESS
:. Gz:/bin/gzip-cd % s: T_REG | T_ASCII: O_UNCOMPRESS: GUNZIP
:::. Gz:/bin/gzip-9-c % s: T_REG: O_COMPRESS: GZIP
:::. Tar:/bin/tar-c-f-% s: T_REG | T_DIR: O_TAR: TAR
:. Tar. Z:/bin/tar-c-Z-f-% s: T_REG | T_DIR: O_COMPRESS | O_TAR: TAR + COMPRESS
: .Tar.gz:/bin/tar-c-z-f-% s: T_REG | T_DIR: O_COMPRESS | O_TAR: TAR + GZIP
:::. Crc:/bin/cksum % s: T_REG: CKSUM
:::. Md5:/bin/md5sum % s: T_REG: MD5SUM
  
Change the file attribute to 600:
[Root @ deep] # chmod 600/etc/ftpconversions
Configure the "/etc/pam. d/ftp" File
Configure the "/etc/pam. d/ftp" file to support PAM security verification.
Create an ftp file (touch/etc/pam. d/ftp) and add it:
# % PAM-1.0
Auth required/lib/security/pam_listfile.so item = user sense = deny file =/etc/ftpusers onerr = succeed
Auth required/lib/security/pam_pwdb.so shadow nullok
Auth required/lib/security/pam_shells.so
Account required/lib/security/pam_pwdb.so
Session required/lib/security/pam_pwdb.so
Configure the "/etc/logrotate. d/ftpd" File
Configure the "/etc/logrotate. d/ftpd" file so that the log file is automatically updated cyclically every week.
Create the "ftpd" file (touch/etc/logrorate. d/ftpd) and add:
/Var/log/xferlog {
# Ftpd doesn' t handle SIGHUP properly
Nocompress
}
Configure ftp to use inetd super server (for tcp-wrappers)
Tcp-wrappers is used to start and stop the ftpd service. When inetd is executed, it reads the configuration information from the configuration file "/etc/inetd. conf" by default. Items in each row in the configuration file are separated by tabs or spaces.
Edit inetd. conf file (vi/etc/inetd. conf), add and verify whether the following line exists: ftp stream tcp nowait root/usr/sbin/tcpd in. ftpd-l-
Note: After updating the "inetd. conf" file, send a SIGNUP signal to inetd and run the following command:
[Root @ deep/root] # killall-HUP inetd
Edit the "hosts. allow" file (vi/etc/hosts. allow) and add it to this line:
In. ftpd: 192.168.1.4 win.openarch.com
This indicates that computers with the IP address "192.168.1.4" and the host name "win.openarch.com" are allowed to access the ftp server.
FTP management tools
Ftpwho
Ftpwho displays all users currently connected to the ftp server. The output of this command menu is similar to the output of "/bin/ps". Its format is:
<Pid> <time> <tty> <connection details>
<Pid> indicates the process number that ftp daemon is used to process this file transfer, <time> indicates when the user connects to the ftp server, and <tty> always uses a question mark (?) It indicates that the connection is established through ftp instead of telnet. <connection details> tells the connection where the connection comes from, who the user is, and what the user is doing.
The following is an example output by ftpwho:
[Root @ deep] # ftpwho
Service class openarch:
5443? S 0: 00 ftpd: win.openarch.com: admin: IDLE
-1 users (20 maximum)
You can see that there is currently a User Logon (up to 20 users can log on at the same time). The user's username is admin from win.openarch.com.
Ftpcount
Ftpcount is a simplified version of ftpwho. It only displays the number of users logging on to the ftp server and the maximum number of users allowed to log on. The following is an example:
[Root @ deep] # ftpcount
Service class openarch-1 users (20 maximum)
  

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.