Configure the ftp service in linux

Source: Internet
Author: User
Redhat9 configure FTP2, edit etcvsftpdvsftpdconf file modify Port Step1 modify etc Redhat9 configure FTP

2. edit the/etc/vsftpd. conf file.
Modify Port

Step 1. modify/etc/vsftpd. conf
'New line below
Listen_port= 2121
Step2. restart vsftpd
[Root @ home vsftpd] #/sbin/service vsftpd restart
Shutting down vsftpd: OK]
Starting vsftpd for vsftpd: OK]
Specific users peter and john cannot change directories
The user's default directory is/home/username. if we do not want the user
To switch to the directory/home on the previous layer, follow these steps.
Step 1. modify/etc/vsftpd. conf
Set the following three lines
# Chroot_list_enable = YES
# (Default follows)
# Chroot_list_file =/etc/vsftpd. chroot_list
Change
Chroot_list_enable = YES
# (Default follows)
Chroot_list_file =/etc/vsftpd/chroot_list // add this file
Step 2: Add a File:/etc/vsftpd/chroot_list
Add two lines to the content:
Peter
John
Step3. restart vsftpd
[Root @ home vsftpd] #/sbin/service vsftpd restart
Shutting down vsftpd: OK]
Starting vsftpd for vsftpd: OK]
If peter wants to switch to a directory other than the root directory, the following warning will appear:
Ftp>; cd/home
550 Failed to change directory.
Cancel anonymous logon
If your host does not require anonymous user login, follow these steps.
Step 1. modify/etc/vsftpd. conf
Set
Anonymous_enable = YES
Change
Anonymous_enable = NO


Arrange welcome words
If we want the user to see the welcome word when logging on, it may include
For more information, see the following steps.
First, check whether this line exists in/etc/vsftpd. conf.
Dirmessage_enable = YES
The default value of RedHat9 includes the above line.
Next, add the file named. message in each directory, and then assume that there is a usage
Test1, and there is a directory named abc under the root directory of this user, then we first in/home/test1
Add. message, the content is as follows:
Hello ~ Welcome to the home directory
This is for test only...
Next, add. message in the/home/test1/abc Directory. the content is as follows:
Welcome to abc's directory
This is subdir...
When the user logs on to test1, the following message is displayed:
230-Hello ~ Welcome to the home directory
230-
230-This is for test only...
230-
If you switch to the abc directory, the following message is displayed:
250-Welcome to abc's directory
250-
250-This is subdir...


Independent processes are used for each online operation.
Generally, when vsftp is started, we only see that a process named vsftpd is running.
If the reader wants to present each online object in an independent process, perform the following steps.
Step 1. modify/etc/vsftpd. conf
Add the following line
Setproctitle_enable = YES
Step2. restart vsftpd
[Root @ home vsftpd] #/sbin/service vsftpd restart
Shutting down vsftpd: OK]
Starting vsftpd for vsftpd: OK]
You can use the ps-ef command to view the online situation of different users, as shown in:
[Root @ home vsftpd] # ps-ef | grep ftp
Root 2090 1 0 00:00:00 pts/0 vsftpd: LISTENER
Nobody 2120 2090 0? 00:00:00 vsftpd: 192.168.10.244:
Connected
Test1 2122 2120 0? 00:00:00 vsftpd: 192.168.10.244/test1:
IDLE
Nobody 2124 2090 0? 00:00:00 vsftpd: 192.168.10.244:
Connected
Test2 2126 2124 0? 00:00:00 vsftpd: 192.168.10.244/test2:
IDLE
Root 2129 1343 0 00:00:00 pts/0 grep ftp
[Root @ home vsftpd] #
Limit the speed of file transfer: the maximum speed of the local user is 200 KBytes/s, anonymous login
The maximum speed is 50 KBytes/s.
Step 1. modify/etc/vsftpd. conf
Add the following two lines
Anon_max_rate = 50000
Local_max_rate = 200000
Step2. restart vsftpd
[Root @ home vsftpd] #/sbin/service vsftpd restart
Shutting down vsftpd: OK]
Starting vsftpd for vsftpd: OK]
The speed here is measured in Bytes/s, where anon_max_rate is restricted by anonymous login.
User, while local_max_rate limits the user of the local machine. Speed limit of VSFTPD
The maximum speed is 80% KBytes/s,
However, the actual speed may be between 80 KBytes/s and 120 KBytes/s. of course, if the bandwidth is insufficient
The value is lower than this limit.
Build an ftp server under the firewall and use port ftp mode: default ftp
Port: 21 and ftp data port: 20
After VSFTPD is started, run the following two lines of commands, which can only be opened at port 21 and port 20,
Disable other settings.
Iptables-a input-p tcp-m multiport -- dport 21,20-j ACCEPT
Iptables-a input-p tcp-j REJECT -- reject-with tcp-reset
Merge vsftpd into XINETD
If the reader wants to incorporate vsftpd into XINETD, that is, the preset settings of version 7.x, then
Readers can perform the following steps.
Step 1. modify/etc/vsftpd. conf
Set
Listen = YES
Change
Listen = NO
Step 2: Add a File:/etc/xinetd. d/vsftpd
The content is as follows:
Service vsftpd
{
Disable = no
Socket_type = stream
Wait = no
User = root
Server =/usr/sbin/vsftpd
Port = 21
Log_on_success + = PID HOST DURATION
Log_on_failure + = HOST
}
Step3. restart xinetd
[Root @ home vsftpd] #/sbin/service xinetd restart
Stopping xinetd: OK]
Starting xinetd: OK]
3. common errors
Ftp client connection failures
Symptom 0:
> Ftp: connect: the connection is rejected.
Cause: The service is not started.
Solution: # chkconfig vsftpd on

Symptom 1:
500 OOPS: cannot open user list file
Cause: The File "/etc/vsftpd. user_list" does not exist or the account does not exist in the file.
Solution: # echo username>/etc/vsftpd. user_list

Symptom 2:
530 Permission denied.
Login failed.
Cause: The current login user does not exist in the "/etc/vsftpd. user_list" file.
Solution: # echo username>/etc/vsftpd. user_list

Symptom 3:
500 OOPS: cannot open chroot () user list file
Login failed.
Cause: The File "/etc/vsftpd. chroot_list" does not exist"
Solution: # echo username>/etc/vsftpd. chroot_list

Symptom 4:
500 OOPS: missing value in config file
Connection closed by remote host.
Cause: "=" There is a problem with the value before the equal sign, or there is only one space
Solution: Correct the corresponding value, and compare and search through diff.

Symptom 5:
500 OOPS: bad bool value in config file
Connection closed by remote host.
Cause: The value after equal sign (=) is incorrect.
Solution: confirm and modify the value after "= ".

Symptom 6:
500 OOPS: unrecognised variable in config file
Connection closed by remote host.
Cause: there is a space before the parameter
Solution: delete the space before the parameter

Symptom 7,
Check whether "local_enable = YES" exists, but the local user cannot log in.
Cause: The verification parameter is deleted by mistake.
Solution: add "pam_service_name = vsftpd"

Symptom 8,
500 OOPS: chdir
500 OOPS: child died
Connection closed by remote host.
Cause: The user's home directory has no permission or has no home directory
Solution: correctly set the user's home directory permissions

553 cocould not create file.

To solve this problem, you only need:
1. setsebool-P ftpd_disable_trans 1
2. service vsftpd restart

1. set selinux
Vi/etc/sysconfig/selinux
Change SELINUX = enforcing to SELINUX = disabled.
2. set as follows:
Setsebool-P allow_ftpd_full_access 1

Chmod-R 765/etc/home

1. check the status of SELinux: sestatus-B | grep ftp

2. in the displayed result, you can see

Ftp_home_dir off

Tftpd_disable_trans off

And so on. Now we only need to set one of them to on.

3. setsebool-P ftpd_disable_trans on or setsebool-P ftp_home_dir on

4. restart vsftpd: service vsftpd restart
Related Article

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.