Install FTP server for Ubuntu

Posted by think-digitally on Mon, 22 Nov 2021 18:20:00 +0100

install

Install ftp server

sudo apt install vsftpd

Software management

Software management mode

service vsftpd start   start-up
service vsftpd restart  restart
service vsftpd stop    stop it
service vsftpd status  View status

Anonymous access method

Modify profile

gedit /etc/vsftpd.conf

Write configuration

anonymous_enable=YES
anon_root= /data/pub
local_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
#listen_ipv6=NO
pam_service_name=vsftpd
userlist_enable=NO
tcp_wrappers=YES

Create folders and files and restart the server

mkdir -p /data/pub
touch /data/pub/a.txt
chmod -R 777 /data
chmod a-w /data/pub
service vsftpd restart 

Client login server

Command line login

ftp 127.0.0.1
 Then enter the user name
Anonymous
 Last input ls If the effect shown in the figure first appears, it means that the creation is successful

Connect to server under folder

Use the folder to access the server. Finally, you can see the file 1.txt under the folder

Access under window

Get the ip address of linux

ifconfig

Enter the address under the file manager in the window

ftp://192.168.183.128

System user access

Modify profile

Modify profile

gedit /etc/vsftpd.conf

Write configuration

anonymous_enable=NO
local_enable=YES
userlist_enable=YES
userlist_deny=NO

Write the user name that allows access

gedit /etc/vsftpd.user_list

Add your own user. For example, if my computer user is ubuntu, write ubuntu in the file

Restart after configuration

service vsftpd restart  

Client login server

The ftp can also be accessed in three ways

Command line login

Connect to server under folder

Access under window

Virtual user access mode

Installation tools

Install the following tools to generate password account verification

sudo apt install db-util

Create account

Create a new ftpuser account and change the password

useradd ftpuser -s /sbin/nologin
passwd ftpuser 

Modify overall configuration

gedit /etc/vsftpd.conf

Write configuration

anonymous_enable=NO
local_enable=YES
userlist_enable=YES
#userlist_deny=NO

guest_enable=YES
guest_username=ftpuser  #Consistent with the user name created earlier
virtual_use_local_privs=YES
pam_service_name=vsftpd
user_config_dir=/etc/vsftpd/virtualconf  #Remember this path

Create a configuration folder to store the configuration of each user

mkdir -p /etc/vsftpd/virtualconf

Create and store user password

vi /etc/vsftpd/virtusers

Deposit the account and password in the file

Generate database files using db command

db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db

Modify pam configuration file

gedit /etc/pam.d/vsftpd

Delete all the contents of the file and replace the following configuration

auth required /lib/x86_64-linux-gnu/security/pam_userdb.so db=/etc/vsftpd/virtusers
account required /lib/x86_64-linux-gnu/security/pam_userdb.so db=/etc/vsftpd/virtusers

Configure per user information

Switch to user configuration directory

mkdir -p /home/ftpuser/ftp1
chown ftpuser.ftpuser /home/ftpuser
cd /etc/vsftpd/virtualconf/
gedit ftp1

Write the following configuration

local_root=/home/ftpuser/ftp1
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES

Configuration complete

Client login server

Restart the following ftp servers

service vsftpd restart

Create a file for subsequent validation review

touch /home/ftpuser/ftp1/1.txt

Login in three ways

Command line login

You can see that 1.txt is the file just created


Connect to server under folder

Topics: OpenCV Ubuntu Computer Vision