Ubuntu 16.04 install ftp server to transfer files

(1) Create a user

I believe that everyone's linux introductory teaching materials are "Brother Bird's Private Kitchen", however, when I actually operate it, I found that it is not the same. In fact, Ubuntu has its own default settings. If you also use the useradd command, the user home directory will not be automatically created under /home.

Later, I found out that Ubuntu is not actually doing things on purpose, but greatly simplifies our operations ------- Let's talk about the adduser command!

This command is actually a perl script, which is a more friendly front-end for useradd and other similar low-level commands. It will create a new user in an interactive way. Using it, you can specify the new user's home directory, login password, whether to encrypt the home directory, etc. ,it will:

1. Create a new directory as the home directory
2. Create a new group with the same name
3. Set the user's primary group to this group (unless command options override the default actions above, such as --disall-homdirecry, etc.)
4. From /etc/SKEL Copy the files in the directory to the home directory, complete the initialization
5. Create a new user's password
6. If it exists, it will also execute a script.

The whole process only needs one command (such as sudo adduser username), is it very simple? Let's take a look at the execution effect. Suppose we want to create a user xuanxufeng_1:

Let's follow the prompts step by step!

We can see that the home directory has been automatically created for the user xuanxufeng_1 under /home, is it much more convenient than the useradd command.

(2) Add sudo permissions for ordinary users

The user just created does not actually have the authority of the super user. If you use the sudo+ command to escalate the authority, the system will give you an error.

But the author is thinking that the original intention of the teacher is to hope that the operations of each user do not affect each other, and users should be isolated. Should I give each user super authority? But if it is not given, sudo is required for the construction of many environments, so what should we do in this case? I don't quite understand here, I hope you can give me some pointers, I'm not very grateful! ! !

 Here's how to configure sudoers:

 The configuration file for the sudo function is generally here: /etc/sudoers, which can be edited with gedit. However, it is stated in the comments of the configuration file of /etc/sudoers that it is not recommended to modify /etc/sudoers directly, but to complete the configuration by adding a new file to the /etc/sudoers.d/ folder.

 Please consider adding local content in /etc/sudoers.d/ instead of directly modifying this file.

 The newly added file can be edited with gedit. For example, to add sudo permissions to xuanxufeng_1, add a file. The file name does not matter. The content is:

xuanxufeng_1 ALL=(ALL) ALL

save, exit.

 Then you need to set the file permissions to 400:  chmod  400  xuanxufeng_1  

After logging in with the xuanxufeng_1 user, you can use sudo privileges.

Note: Ubuntu10.04 (11.04 is good, other versions have not been tested) has a serious bug. After adding a file in /etc/sudoers.d/, if this file is not 400 permissions, you cannot use sudo again. The system crashes! If you want to modify the file attributes, you cannot modify it. Ubuntu default root cannot log in directly. If this has happened, you can only restart to single-person maintenance mode, set the file permissions and restart! What a disaster for a machine hosted in a server room!

 If you want to avoid this situation, do not add files with sudo, but log in with sudo su root instead of root, and then create a file to modify the file permissions. You can modify it because root has not exited at this time.

(3) Ubuntu16.04 install ftp server

 Here is the point.

sudo apt-get update
sudo apt-get install vsftpd 

After performing this step, the vsftpd service has been installed

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

(a) Add the following to the file:

copy code
userlist_deny=NO 
userlist_enable=YES 
#Allow logged in users
userlist_file=/etc/allowed_users 
seccomp_sandbox=NO 
local_enable=YES 
#Set file upload
write_enable=YES 
#use utf8
utf8_filesystem=YES
copy code

 

Make "local_enable=YES" in the file to save.

(b) Create a new /etc/allowed_users file

sudo gedit /etc/allowed_users

Suppose I only want xuanxufeng and root to access the ftp server, then enter xuanxufeng, root-->Save OK! In the future, when there are other users using ftp, you can directly add the user name!

(c) Use gedit to view the contents of the /etc/ftpuusers file

sudo gedit /etc/ftpusers

打开这个文件后,看一看有没有uftp这个用户名,如果没有,就直接退出。如果有就删除uftp,因为这个文件中记录的是不能访问FTP服务器的用户清单。

重启vsftp服务器。

2. 启动停止重启服务

sudo /etc/init.d/vsftpd start
sudo /etc/init.d/vsftpd stop
sudo /etc/init.d/vsftpd restart

3. 访问ftp服务器

sudo ftp 127.0.0.1

浏览器访问 

ftp://127.0.0.1 

或者 

ftp://localhost

远程访问时使用实际ip:  ftp://your_ip 

4. windows下简单有效地访问ftp服务器

我们有三种方式可以访问(假设服务器ip地址是:172.16.23.33)

(1)浏览器

在浏览器中输入ftp://172.16.23.33,运行结果如下:

(2)使用文件传输软件(比如8uftp):

按道理讲,访问权限仅限于xuanxufeng这个用户的主目录,但是这个软件真特么的强大,它竟然能越过我的主目录,访问整个系统!好怕怕=。=

In addition, there is a problem of garbled characters here. Since the focus of this article is not here, I am too lazy to care about this. Interested readers can try to solve it by themselves.

(3) Finally, let me introduce the most convenient method~ Windows is actually quite convenient, and it is not useless~

Double-click "Computer" and enter: ftp://172.16.23.33/ in the address bar , but it doesn't work....

Don't worry~ Right click and select Login~~~

 

Are you in now? This actually corresponds to the home directory of the user xuanxufeng under linux! The rest of the file upload and download is the same as the file operation under Windows, isn't it very convenient! ! !
-------------------------------------------------- --------Labor and capital are the dividing line-------------------------------------- -------------------------------------------------
Well, the server construction is basically completed. In the future, for each additional user on the server, a user will be created, and then the user will be added in /etc/allowed_users and it will be OK!

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326013858&siteId=291194637