Home>

First, due to the requirements of the course this afternoon, I had to do an experiment on setting up an ftp server on Ubuntu.But the experimental instructions are still n years ago,Searched a lot online,It's all vague!

Finally succeeded in trial and error,I would like to share my experience with you, I hope everyone will take less detours!

The detailed steps are as follows:

(1) First open the terminal and enter the root mode (enter:sudo su in the terminal and prompt for the password).

(2) Install vsftpd software (first to network,Or install it through Synaptic software! Uninstall software command:sudo apt-get remove vsftpd )

<span>command:sudo apt-get install vsftpd</span>

(3) After successful installation,By default, an ftp file is created in the srv directory under the file system (in the same directory as home), here is the default folder of the ftp server!

(4) Some documents say that the directory automatically created on the ftp server is the ftp folder under the home directory, but I have never found it (usually the user's directory is under the home directory). I created it myself to access ftp It was not found at the time!

(5) Add folders and files to the server directory,First create a folder test under srv/ftp/(manually cannot be created,Only through commands! )

Command:mkdir/srv/ftp/test

Get the created folder:

Create a few more directories just for testing!

(6) Create a file in the test folder:touch /srv/ftp/test/1.txt file

(7) Edit the 1.txt file:(Due to the management of permissions,Need to change the contents of the file using root mode! )

sudo gedit /srv/ftp/test/1.txt will pop up a notepad file that can be modified only when opened under root privileges |! Add some content

(8) To illustrate a command,Restart it!

The command is:sudo /etc/init.d/vsftpd restart

Enter test to find the 1.txt file Click to enter!

(10) OK! That's it!

Third, the above knowledge introduced the general default configuration,We usually need to configure according to our needs,Here are some common configurations!

If you need to modify it, you still need to modify it under root authority. Use the command:sudo gedit /etc/vsftpd.conf

(1) Related settings for anonymous users

anonymous_enable=yes, change yes to no to prevent anonymous users from logging in #anon_mkdir_write_enable=yes, remove the #comment,Allow anonymous users to create directories #non_upload_enalbe=yes, remove #to allow anonymous users to upload anon_world_readable_only=yes, allow anonymous users to download,Disabled by default,This can be added by yourself. anon_other_write_enable=yes, if it is set to yes, in addition to uploading and creating directories,You can also rename,Delete Files,Default is no no_anon_password=no, set it to yes, anonymous users will not query the user password and log in directly. ftp_username=ftp, the default login account for anonymous users is ftp, it is best not to change this; chroot_local_user=yes #Restrict local users to their home folder,In this way, you cannot access files outside your home after logging in.This is for security reasons anon_root =/var/ftp/anon #Specify the root folder after anonymous login,For anonymous users,Will map/var/ftp/anon to its root directory

(2) Designation of FTP service port

listen_port=8021, specify the command channel as 8021, default is 21 listen_data_port=8020, the specified data channel is 8020, the default is 20

(3) Setting of upload mode

pasv_enable=yes, whether to allow passive mode,Allowed by default. pasv_min_port=10000, specifies the minimum value to open the port when using passive mode pasv_max_port=10004, which specifies the maximum number of ports to be opened when using passive mode.

(4) vsftp server specified IP address

listen_address=192.168.0.21, specify ftp, ip address

Note:The specified IP is only allowed when vsftp is running in independent mode. If the vsfpd file has been created in the /etc/xinetd.d directory, you must set the disable in this file to yes.

(5) lock users,Prevent user from leaving user home directory

chroot_local_user=yes, set it to yes, it will be locked in the user's home directory,Set to no, you can switch

Set the specified user to lock the user's home directory:

#chroot_list_enable=yes
#chroot_list_file =/etc/vsftpd.chroot_list

Change it to the following:

chroot_list_enable=no
chroot_list_file =/etc/vsftpd/vsftpd.chroot_list

Save the above,Then do the following:

#touch /etc/vsftpdvsftpd.chroot_list
#vi /etc/vsftpd/vsftpd.chroot_list, add the user list to the file,Example:netseek_com

(6) Flow control of vsftpd server

max_clients=100;the maximum number of connections allowed,Defined as 100, default is 0, the table is unlimited max_per_ip=5;the number of connections allowed per ip,0 table without restrictions,Need to run in standalone mode anon_max_rate=50000;Maximum bandwidth for anonymous users,The unit is bps local_max_rate=200000;system user maximum bandwidth

(7) vsftpd customized welcome message

Directory description settings

#vi /etc/vsftpd.conf
#dirmessage_enable=yes, the previous #remove.

Then we customize one.message, write what i want to write,Then copy this file to the home directory of each user,Just ok.

(9) vsftpd system welcome message settings

ftpd_banner=welcometoftp.netseek.com, yeah !!!

System welcome message file settings

banner_file =/etc/vsftpd/welcome is similar to ftpd_banner, except thatbanner_file specifies the welcome file.

Create users

But you cannot upload files.Because this is an anonymous user,The current directory owner is the root user;really want to upload files to create a folder under this directory, such as the name upload,

$sudo mkdir/srv/ftp/upload
$sudo chown ftp:root/srv/ftp/upload

At this time, you can transfer files to the upload directory, but the root directory still cannot upload files.This is an anonymous user.This problem does not exist if it is not an anonymous user.

1). Modify the configuration file /etc/vsftpd.conf

anonymous_enable=no
local_enable=yes
write_enable=yes
chroot_local_user=yes

2). Create a local user

$sudo useradd ftpuser -m
$sudo passwd ftpuser

You can log in to ftp with ftpuser.

6. If an error occurs:500oops:vsftpd:refusingtorunwithwritableanonymousroot

This means that the ftp user's home directory has incorrect permissions.The permissions of this directory cannot open all permissions;Caused by running chmod777/srv/ftp;if there is no home directory for ftp users,Of course you have to build one yourself;

The home directory of ftp users cannot be completely open to all users, user groups, and other user groups;The solution is as follows:

#chown root:root/srv/ftp
#chmod 755/srv/ftp

7.Firewall opens corresponding ports 21,20

8./etc/init.d/vsftpd restart Restart the service

Five, the explanation of each user

The following describes the three types of users supported by vsftpd:

1. Anonymous users,That is, a user who can log in to the ftp server without entering a password.This username is usually ftp or anonymous;most settings related to anonymous users begin with the anon_ option. 2. Local users,That is, users who can log in to the system on your linux system,These users are users who actually exist on the system.Usually has its own home, shell, etc. Settings related to local users often start with or include local_ options. 3. Virtual users,Only valid for ftp users.These users can't log in to the linux system, they can only log in to the ftp server. In fact, a local user is mapped into multiple virtual users that are only valid for the FTP server.Virtual users can have their own ftp configuration files,Therefore, virtual users are usually used to set different permissions for different users of the ftp system.To achieve the purpose of security control.Settings related to virtual users begin with guest_.

If you just want to share yourself with ftp,You can enable local users;

If i want to share it with many people,Then you can use anonymous users;

If you need to give different permissions to different user groups,Then you need to set up more complex virtual users.

mkdir directory name =>create a directory

rmdir empty directory name =>delete an empty directory

rm file name file name =>delete one file or multiple files

rm -rf non-empty directory name =>delete everything in a non-empty directory

touch filename =>create an empty file

to sum up

  • Previous C # print log summary method
  • Next eclipse cannot connect to genymotion solution