1. 程式人生 > >部署FTP服務、FTP服務主配置檔案引數詳解

部署FTP服務、FTP服務主配置檔案引數詳解

FTP服務

概述:

FTP(File Transfer Protocol),是檔案傳輸協議的簡稱。用於Internet上的控制檔案的雙向傳輸。同時,
它也是一個應用程式(Application),使用者可以通過它把自己的PC機與世界各地所有執行FTP協議的伺服器相連,
訪問伺服器上的大量程式和資訊。
FTP的主要功能是實現各種作業系統之間的檔案交流,建立一個統一的檔案傳輸協議。
ftp://      ##檔案傳輸協議
vsftpd      ##FTP伺服器包

實驗環境:

服務端:server  172.25.254.234  
客戶端:物理機  172.25.254.34  

注意:所有配置都在服務端,而客戶端只是用來測試

安裝包:

服務端: vsftd
客戶端: lftp

1.部署ftp服務

在服務端:

(1).安裝FTP伺服器包並開啟服務

##安裝FTP伺服器包vsftpd
[[email protected] ~]# yum install -y vsftpd 
##開啟服務
[[email protected] ~]# systemctl start vsftpd
[[email protected] ~]# systemctl enable vsftpd

(2).新增防火牆策略(或者直接關閉火牆)

[[email protected]
~]# systemctl status firewalld

在這裡插入圖片描述

##新增防火牆策略,讓火牆允許ftp服務; --permanent表示永久新增
[[email protected] ~]# firewall-cmd --permanent --add-service=ftp
Success
##重新載入;必須執行,否則不生效
[[email protected] ~]# firewall-cmd --reload
success
[[email protected] ~]# firewall-cmd --list-all

在這裡插入圖片描述
(3)關閉selinux(因為selinux會影響後續實驗)

##檢視selinux的狀態
[[email protected] ~]# getenforce
Enforcing
[[email protected] ~]# vim /etc/sysconfig/selinux 
###############
SELINUX=disabled

在這裡插入圖片描述

##必須重啟才能生效
[[email protected] ~]# reboot
[[email protected] html]# ssh [email protected]
[[email protected] ~]# getenforce

在這裡插入圖片描述
配置客戶端:

(1)安裝lftp

##檢測該主機已經安裝過lftp
[[email protected] ~]$ rpm -q lftp

在這裡插入圖片描述
(2).測試:ls不報錯即視為連線成功

[[email protected] ~]$ lftp 172.25.254.234                              
lftp 172.25.254.234:~> ls              
drwxr-xr-x    2 0        0               6 Mar 07  2014 pub
lftp 172.25.254.234:/> exit

在這裡插入圖片描述
@排錯:ls時出現Interrupt,即無法連線。

(1)vsftpd服務沒有開啟
(2)防火牆未關閉,也沒有新增防火牆策略

2.ftp服務的基本資訊

軟體安裝包:   vsftpd
預設釋出目錄: /var/ftp
協議介面:     21/tcp
服務配置檔案: /etc/vsftpd/vsftpd.conf 
報錯id的解析:
        500    ##檔案系統許可權過大
        530    ##使用者認證失敗
        550    ##服務本身功能未開放 
        553    ##檔案權過小

實驗:

##查詢軟體的配置檔名稱
[[email protected] ~]# rpm -qc vsftpd

在這裡插入圖片描述

##/var/ftp/為FTP服務的預設釋出目錄
[[email protected] ~]# cd /var/ftp/
[[email protected] ftp]# ls

在這裡插入圖片描述

##檢視幫助
[[email protected] Desktop]$ man 5 vsftpd.conf

在這裡插入圖片描述
3.ftp服務主配置檔案引數的設定

@@1.預設匿名使用者和本地使用者登陸可以登陸

$1.匿名使用者登陸
在客戶端:
##匿名使用者登陸
[[email protected] ~]$ lftp 172.25.254.234
lftp 172.25.254.234:~> ls              
drwxr-xr-x    2 0        0               6 Mar 07  2014 pub
lftp 172.25.254.234:/> exit

在這裡插入圖片描述

$2.本地使用者登陸
在服務端:
##建立使用者
[[email protected] ~]# id student
uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)
[[email protected] ~]# id westos
id: westos: no such user
[[email protected] ~]# useradd westos

在這裡插入圖片描述

##更改使用者密碼
[[email protected]ocalhost ~]# passwd student
[[email protected] ~]# passwd westos

在這裡插入圖片描述

在客戶端:
##本地使用者登陸
[[email protected] ~]$ lftp 172.25.254.234 -u student
Password: 
lftp [email protected]:~> ls      
lftp [email protected]:~> exit

在這裡插入圖片描述

[[email protected] ~]$ lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
lftp [email protected]:~> exit

在這裡插入圖片描述
@2.預設本地使用者的登陸在使用者家目錄

在服務端:
[[email protected] ~]# cd /home/student
[[email protected] student]# ls
[[email protected] student]# touch studentfile
[[email protected] student]# ls
studentfile

在這裡插入圖片描述
在客戶端:
在這裡插入圖片描述
在服務端:

[[email protected] student]# cd /home/westos
[[email protected] westos]# ls
[[email protected] westos]# touch westosfile{1..3}
[[email protected] westos]# ls
westosfile1  westosfile2  westosfile3

在這裡插入圖片描述
在客戶端:

[[email protected] ~]$ lftp 172.25.254.234 -u westos

在這裡插入圖片描述
@3.預設本地使用者可以的登陸、上傳、刪除、新建目錄

##本地使用者登陸
[[email protected] ~]$  lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
##上傳檔案
lftp [email protected]:~> put /etc/passwd
3190 bytes transferred
lftp [email protected]:~> ls
-rw-r--r--    1 1001     1001         3190 Oct 31 15:19 passwd
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
##刪除檔案
lftp [email protected]:~> rm passwd
rm ok, `passwd' removed
lftp [email protected]:~> ls
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
##新建目錄
lftp [email protected]:~> mkdir hello
mkdir ok, `hello' created
lftp [email protected]:~> ls
drwxr-xr-x    2 1001     1001            6 Oct 31 15:20 hello
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
##但不能用使用touch命令  因為ftp服務介面並非支援所有shell中的所有命令
lftp [email protected]:~> touch file
Unknown command `touch'.
lftp [email protected]:~> exit

在這裡插入圖片描述
@@預設匿名使用者不能刪除、下載、建立目錄

在服務端:
[[email protected]calhost ~]# cd /var/ftp
[[email protected] ftp]# ls
pub
[[email protected] ftp]# cd pub
[[email protected] pub]# ls
[[email protected] pub]# mkdir file{1..3}
[[email protected] pub]# ls
file1  file2  file3

在這裡插入圖片描述

在客戶端:
[[email protected] ~]$ lftp 172.25.254.234
lftp 172.25.254.234:~> ls
drwxr-xr-x    5 0        0              42 Oct 31 15:56 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
lftp 172.25.254.234:/pub> rm file1
rm: Access failed: 550 Permission denied. (file1)
lftp 172.25.254.234:/pub> put /etc/passwd
put: Access failed: 550 Permission denied. (passwd)
lftp 172.25.254.234:/pub> mkdir test
mkdir: Access failed: 550 Permission denied. (test)
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
本地使用者引數設定:

(1).本地使用者是否可以登陸

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
################
local_enable=NO  ##不允許本地使用者登陸

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd
[[email protected] Desktop]$ lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
ls: Login failed: 530 This FTP server is anonymous only.
lftp [email protected]:~> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
############### 
local_enable=YES  ##允許本地使用者登陸

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd

在這裡插入圖片描述
(2).指定本地使用者家目錄

[[email protected] ~]# mkdir /westos
[[email protected] ~]# touch /westos/linux{1..3}
[[email protected] ~]# ll /westos

在這裡插入圖片描述

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
local_root=/westos   #更改本地使用者家目錄為/westos

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd
[[email protected] ~]$  lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
-rw-r--r--    1 0        0               0 Oct 31 16:07 linux1
-rw-r--r--    1 0        0               0 Oct 31 16:07 linux2
-rw-r--r--    1 0        0               0 Oct 31 16:07 linux3
lftp [email protected]:~> exit
[[email protected] ~]$  lftp 172.25.254.234 -u student
Password: 
lftp [email protected]:~> ls      
-rw-r--r--    1 0        0               0 Oct 31 16:07 linux1
-rw-r--r--    1 0        0               0 Oct 31 16:07 linux2
-rw-r--r--    1 0        0               0 Oct 31 16:07 linux3
lftp [email protected]:~> exit

在這裡插入圖片描述

[[email protected] ~]# cd /home/westos
[[email protected] westos]# ls
hello  westosfile1  westosfile2  westosfile3
[[email protected] westos]# cd /home/student
[[email protected] student]# ls
studentfile

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
################
#local_root=/westos

在這裡插入圖片描述

[[email protected] student]# systemctl restart vsftpd

在這裡插入圖片描述
(3).指定本地使用者上傳檔案的許可權 (預設為644)

##預設許可權為644
[[email protected] ~]$ lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
drwxr-xr-x    2 1001     1001            6 Oct 31 15:20 hello
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
lftp [email protected]:~> put /etc/passwd
3190 bytes transferred
lftp [email protected]:~> ls
drwxr-xr-x    2 1001     1001            6 Oct 31 15:20 hello
-rw-r--r--    1 1001     1001         3190 Oct 31 16:23 passwd
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
lftp [email protected]:~> exit

在這裡插入圖片描述

[[email protected] student]# vim /etc/vsftpd/vsftpd.conf
####################
24 local_umask=077  ##更改本地使用者上傳檔案的許可權

在這裡插入圖片描述

[[email protected] student]# systemctl restart vsftpd
[[email protected] ~]$ lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
drwxr-xr-x    2 1001     1001            6 Oct 31 15:20 hello
-rw-r--r--    1 1001     1001         3190 Oct 31 16:23 passwd
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
lftp [email protected]:~> put /etc/inittab 
510 bytes transferred
lftp [email protected]:~> ls
drwxr-xr-x    2 1001     1001            6 Oct 31 15:20 hello
-rw-------    1 1001     1001          510 Oct 31 16:26 inittab
-rw-r--r--    1 1001     1001         3190 Oct 31 16:23 passwd
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
lftp [email protected]:~> exit

在這裡插入圖片描述
還原:

[[email protected] student]# vim /etc/vsftpd/vsftpd.conf
####################
#local_root=/westos

在這裡插入圖片描述

[[email protected] student]# systemctl restart vsftpd

匿名使用者設定:

(1).匿名使用者是否可以登陸

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
############### 
12 anonymous_enable=NO  #不允許匿名使用者登陸

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd
[[email protected] ~]$ lftp 172.25.254.234
lftp 172.25.254.234:~> ls
Interrupt   
lftp 172.25.254.234:~> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
###############
12 anonymous_enable=YES  #允許匿名使用者登陸

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd

在這裡插入圖片描述
(2).如何讓匿名使用者可以put上傳檔案

@預設匿名使用者不能使用put上傳

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
##############
29 anon_upload_enable=YES  #取消註釋即可,允許匿名使用者可以上傳

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls 
drwxr-xr-x    5 0        0              42 Oct 31 15:56 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
lftp 172.25.254.234:/pub> put /etc/passwd
put: Access failed: 553 Could not create file. (passwd)   #本地檔案許可權過小
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述

##更改檔案組和許可權
[[email protected] ~]# ll /var/ftp
total 0
drwxr-xr-x. 5 root root 42 Oct 31 11:56 pub
[[email protected] ~]# chgrp ftp /var/ftp/pub/
[[email protected] ~]# chmod g+w /var/ftp/pub/
[[email protected] ~]# ll /var/ftp
total 0
drwxrwxr-x. 5 root ftp 42 Oct 31 11:56 pub

在這裡插入圖片描述

[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    5 0        50             42 Oct 31 15:56 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
lftp 172.25.254.234:/pub> put /etc/passwd
3190 bytes transferred
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-------    1 14       50           3190 Oct 31 16:44 passwd
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
(3).如何讓匿名使用者可以get下載檔案

預設匿名使用者不能下載檔案

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
30 anon_world_readable_only=NO  #允許匿名使用者下載

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    5 0        50             55 Oct 31 16:44 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-------    1 14       50           3190 Oct 31 16:44 passwd
lftp 172.25.254.234:/pub> get passwd 
3190 bytes transferred
lftp 172.25.254.234:/pub> exit
[[email protected] ~]$ ls
Desktop    Downloads  passwd  Pictures  PycharmProjects  Videos      westos
Documents  Music      perl5   Public    Templates        Wallpapers

在這裡插入圖片描述

(3)如何讓匿名使用者可以刪除檔案

預設匿名使用者不能刪除

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
31 anon_other_write_enable=YES  #允許匿名使用者刪除

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    5 0        50             55 Oct 31 16:44 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-------    1 14       50           3190 Oct 31 16:44 passwd
lftp 172.25.254.234:/pub> rm passwd 
rm ok, `passwd' removed        
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
(4)如何讓匿名使用者可以建立目錄

預設匿名使用者不能建立目錄

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
###############
anon_mkdir_write_enable=YES  ##取消註釋即可,允許匿名使用者建立目錄

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    5 0        50             42 Oct 31 16:58 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> mkdir westos
mkdir ok, `westos' created
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
(5)更改匿名使用者家目錄

[[email protected] ~]# mkdir /hello
[[email protected] ~]# touch /hello/lee{1..3}
[[email protected] ~]# ls /hello/
lee1  lee2  lee3
[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
30 anon_root=/linux  ##更改匿名使用者家目錄

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
-rw-r--r--    1 0        0               0 Oct 31 17:06 lee1
-rw-r--r--    1 0        0               0 Oct 31 17:06 lee2
-rw-r--r--    1 0        0               0 Oct 31 17:06 lee3
lftp 172.25.254.234:/> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
###############
#anon_root=/linux  

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 

在這裡插入圖片描述
(6)更改匿名使用者上傳檔案預設許可權

##預設許可權為600
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    6 0        50             55 Oct 31 17:02 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
31 anon_umask=022

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    6 0        50             55 Oct 31 17:02 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> put /etc/inittab 
510 bytes transferred      
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-r--r--    1 14       50            510 Oct 31 17:14 inittab
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
#anon_umask=022

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 

在這裡插入圖片描述
(7).修改匿名使用者上傳檔案使用身份(檔案所有人)及檔案許可權

[[email protected] ~]# id student
uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)
[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
###############
chown_uploads=YES         ##允許對上傳檔案做更改
chown_username=student     ##更改檔案所有人
chown_upload_mode=0644    ##更改檔案許可權

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd
[[email protected] ~]$ lftp 172.25.254.234
lftp 172.25.254.234:~> ls
drwxrwxr-x    6 0        50             82 Oct 31 17:17 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-r--r--    1 14       50            510 Oct 31 17:14 inittab
-rw-------    1 14       50           3190 Oct 31 17:17 passwd
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> put /etc/group
1195 bytes transferred
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-r--r--    1 1000     50           1195 Oct 31 23:33 group
-rw-r--r--    1 14       50            510 Oct 31 17:14 inittab
-rw-------    1 14       50           3190 Oct 31 17:17 passwd
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
################
#chown_uploads=YES
#chown_username=student
#chown_upload_mode=0644
[[email protected] ~]# systemctl restart vsftpd

匿名使用者和本地使用者相同引數設定:

(1).本地使用者和匿名使用者是否可寫(mkdir rm put)
預設匿名使用者不可寫

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
19 write_enable=NO  ##不允許本地使用者和匿名使用者寫

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd
[[email protected] ~]$ lftp 172.25.254.234
lftp 172.25.254.234:~> ls
drwxrwxr-x    6 0        50             94 Oct 31 23:33 pub
lftp 172.25.254.234:/> mkdir hello
mkdir: Access failed: 550 Permission denied. (hello)
lftp 172.25.254.234:/> rm pub
rm: Access failed: 550 Permission denied. (pub)
lftp 172.25.254.234:/> put /etc/passwd
put: Access failed: 550 Permission denied. (passwd)
lftp 172.25.254.234:/> exit

[[email protected] ~]$ lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls
-rw-r--r--    1 1001     1001         1195 Oct 31 23:54 group
drwxr-xr-x    2 1001     1001            6 Oct 31 15:20 hello
-rw-------    1 1001     1001          510 Oct 31 16:26 inittab
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile1
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile2
-rw-r--r--    1 0        0               0 Oct 31 15:18 westosfile3
lftp [email protected]:~> mkdir haha
mkdir: Access failed: 550 Permission denied. (haha)
lftp [email protected]:~> rm /etc/group
rm: Access failed: 550 Permission denied. (/etc/group)
lftp [email protected]:~> put /etc/passwd
put: Access failed: 550 Permission denied. (passwd)
lftp [email protected]:~> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
19 write_enable=YES

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd

在這裡插入圖片描述
(2).限速

[[email protected] Desktop]$ dd if=/dev/zero of=/tmp/file bs=1M count=1000

在這裡插入圖片描述

[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls 
drwxrwxr-x    6 0        50             94 Oct 31 23:33 pub
lftp 172.25.254.234:/> cd pub/
lftp 172.25.254.234:/pub> ls
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-r--r--    1 1000     50           1195 Oct 31 23:33 group
-rw-r--r--    1 14       50            510 Oct 31 17:14 inittab
-rw-------    1 14       50           3190 Oct 31 17:17 passwd
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> put /tmp/file
1048576000 bytes transferred in 34 seconds (29.44M/s)                          
lftp 172.25.254.234:/pub> exit
1048576000 bytes transferred in 34 seconds (29.44M/s)                          
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
32 anon_max_rate=102400  ##限制速度

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 
[[email protected] ~]$ lftp 172.25.254.234 
lftp 172.25.254.234:~> ls
drwxrwxr-x    6 0        50           4096 Nov 01 00:14 pub
lftp 172.25.254.234:/> cd pub
lftp 172.25.254.234:/pub> ls
-rw-------    1 14       50       131595856 Nov 01 00:21 file
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file1
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file2
drwxr-xr-x    2 0        0               6 Oct 31 15:56 file3
-rw-r--r--    1 1000     50           1195 Oct 31 23:33 group
-rw-r--r--    1 14       50            510 Oct 31 17:14 inittab
-rw-------    1 14       50           3190 Oct 31 17:17 passwd
drwx------    2 14       50              6 Oct 31 17:02 westos
lftp 172.25.254.234:/pub> put /tmp/file
Interrupt                                                       
lftp 172.25.254.234:/pub> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf 
###############
32 #anon_max_rate=102400  

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd.service 

在這裡插入圖片描述
(3).限制最大連線數(防止過多使用者登入,系統崩潰)

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
###############
33 max_clients=1

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd
[[email protected] ~]$ lftp 172.25.254.234
lftp 172.25.254.234:~> ls              
drwxrwxr-x    6 0        50           4096 Nov 01 00:27 pub
lftp 172.25.254.234:/> 

在這裡插入圖片描述

連線另一個主機:
[[email protected] ~]# ssh [email protected]
[email protected]'s password: 
Last login: Wed Oct 31 20:32:59 2018 from 172.25.254.66
[[email protected] ~]# lftp 172.25.254.234
lftp 172.25.254.234:~> ls
Interrupt                                    
lftp 172.25.254.234:~> exit

在這裡插入圖片描述
還原:

[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
###############
#max_clients=1

在這裡插入圖片描述

[[email protected] ~]# systemctl restart vsftpd

在這裡插入圖片描述
(4).本地使用者黑名單的設定

如果本地使用者都無法登陸,那麼匿名使用者就更不能登陸了

@1.永久性黑名單: ftpusers (無論任何情況下都是黑名單)

[[email protected] ~]# cd /etc/vsftpd/
[[email protected] vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

在這裡插入圖片描述

##即改即生效
[[email protected] vsftpd]# vim ftpusers 
###################
westos

在這裡插入圖片描述

[[email protected] ~]$ lftp 172.25.254.234 -u westos
Password: 
lftp [email protected]:~> ls       
ls: Login failed: 530 Login incorrect.          
lftp [email protected]:~> exit

在這裡插入圖片描述

[[email protected] ~]$ lftp 172.25.254.234 -u student
Password: 
lftp [email protected]:~> ls      
-rw-r--r--    1 0        0               0 Oct 31 15:16 studentfile
lftp [email protected]:~> exit

在這裡插入圖片描述
還原:

[[email protected] vsftpd]# vim ftpusers 
###################
刪除westos

在這裡插入圖片描述
@2.臨時性黑名單: user_list (可以變為白名單)

[[email protected] vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh
[[email protected] vsftpd]# pwd
/etc/vsftpd
[[email protected] vsftpd]# vim user_list 
###################
student

在這裡插入圖片描述

[[email protected] ~]$ lftp 172.25.254.234 -u student
Password: 
lftp [email protected]:~> ls      
ls: Login failed: 530 Permission denied.          
lftp [email protected]:~> exit

在這裡插入圖片描述

[
            
           

相關推薦

部署FTP服務FTP服務配置檔案引數

FTP服務 概述: FTP(File Transfer Protocol),是檔案傳輸協議的簡稱。用於Internet上的控制檔案的雙向傳輸。同時, 它也是一個應用程式(Application),使用者可以通過它把自己的PC機與世界各地所有執行FTP協議的伺服器相連, 訪問伺服器上的

keepalived 配置檔案引數

global_defs 全域性配置vrrpd 1. vrrp_script新增一個週期性執行的指令碼。指令碼的退出狀態碼會被呼叫它的所有的VRRP Instance記錄。 2. vrrp_sync_group將所有相關的VRRP例項定義在一起,作為一個VRRP Group,如果組內的任意一個例項出現問題,都可

LVS原理 && 配置檔案引數

LVS原理詳解   LVS原理詳解 LVS簡介 LVS結構與工作原理 一.LVS的結構 二.LVS核心模型 三.LVS的包轉發模型 1.NAT模型: 2.DR模型:

nginx配置檔案引數

這年頭原創技術博文真心難寫,不可能每天都有靈感,也不可能每天都出問題。而且技術教程也非常全面,不管是百度一下,你就知道,還是谷歌一把,你就找到,基本要啥有啥,只有你想得到,沒有你搜不到。。。如果突然發現搜不到了,那恭喜你,你又可以來個原創研究專案了! 之所以開篇吐槽這麼多,也是因為張戈今天確實沒東西寫,又不

kafka 配置檔案引數

kafka的配置分為 broker、producter、consumer三個不同的配置 一 BROKER 的全域性配置 最為核心的三個配置 broker.id、log.dir、zookeeper.connect 。 ------------------------

hadoop引數彙總配置檔案引數

Hadoop引數彙總 @(hadoop)[配置] linux引數 以下引數最好優化一下: 檔案描述符ulimit -n使用者最大程序 nproc (hbase需要 hbse book)關閉swap分割槽設定合理的預讀取緩衝區Linux的核心的I

nginx高性能WEB服務器系列之四配置文件

pro web服務 發送 應該 避免 如果 upstream index 靜態頁 註:原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任。 nginx的強大之處不必要我細說,當初第一次接觸nginx的時候就發現了它的強大

Nginx配置參數,Nginx配置網站

lis javascrip ref 錯誤日誌 127.0.0.1 服務器配置 設置 代理服務器 減少 1.Niginx主配置文件參數詳解   a.Linux中安裝nginx。博文地址為:http://www.cnblogs.com/cindy-cindy/p/68474

SSH遠端登入配置檔案sshd_config

SSH由客戶端和服務端的軟體組成,在客戶端可以使用的軟體有SecureCRT、putty、Xshell等, 而在伺服器端執行的是一個sshd的服務,通過使用SSH,可以把所有傳輸的資料進行加密,而且也能夠 防止dns和IP欺騙,此外,SSH傳輸的資料是經過壓縮的,可以加快傳輸速度 其伺服器端的配

Spring Boot配置檔案全面

Spring Boot在工作中是用到的越來越廣泛了,簡單方便,有了它,效率提高不知道多少倍。Spring Boot配置檔案對Spring Boot來說就是入門和基礎,經常經常會用到,所以寫下做個總結以便日後檢視。 1.配置檔案 當我們構建完Spring Boot專案後,會在resources目錄下給我們一

Apache2 httpd.conf配置檔案中文版

Apache2 httpd.conf配置檔案中文版詳解## 基於 NCSA 服務的配置檔案。##這是Apache伺服器主要配置檔案。#它包含伺服器的影響伺服器執行的配置指令。#參見以取得關於這些指令的詳細資訊##不要只是簡單的閱讀這些指令資訊而不去理解它。#這裡只是做了簡單的說明,如果你沒有參考線上檔案,你就

Redis 主從配置引數

安裝redis 下載redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解壓redis tar -xvf redis-3.0.7.tar.gz 安裝redis cd redis-3.0.7 “有可能需要安裝g

--Shiro配置檔案ini

2017年07月09日 18:54:02 lfendo 閱讀數:7563  https://blog.csdn.net/u011781521/article/details/74892074 一、INI簡介 INI配置檔案是一種key/value的鍵值對配置

springboot 專案啟動配置tomcat引數

我們都知道spring boot是內建了tomcat伺服器,下面就是 如何在配置檔案裡配置啟動時Tomcat的基本配置: - spring boot預設埠號是8080,如果要修改埠的話,只需要修改application.properties檔案,在其中加入 server.port

Kafka概念和關於springboot配置Kafka引數

1.基本概念 *Producer:            訊息生產者,往Topic釋出訊息 *Consumer:            訊息消費者,往Topic取訊

docker-compose.yml 配置檔案編寫

docker compose 在 Docker 容器運用中具有很大的學習意義,docker compose 是一個整合釋出應用的利器。而使用 docker compose 時,懂得如何編排 docker compose 配置檔案是很重要的。 一. 前言

vagrant系列二:vagrant的配置檔案vagrantfile

上一篇文章完整的講敘瞭如何安裝一個vagrant的環境。這裡主要說一說vagrant的配置檔案Vagrantfile。我在嘗試各種技術的時候,常常苦惱於很多時候沒有教程把相關的配置資訊說明完整。所以在我的部落格裡,我一定會完整的把這塊給補上。 一 配置詳解

MySql主從配置檔案問題(資料不同步解決方案)

一、問題描述 在mysql主從配置搭建好以後,偶爾會出現從庫無法同步主庫資料的情況,經過測試,把產生主從資料不同步的集中情況進行了歸納以及總結,問題如下: 1、主庫丟擲異常, 例如主鍵衝突等情況,這是主從配置就會失效,叢庫就無法同步主庫的資料了。如下

Flume學習7_Flume配置檔案內容

a1.sources = r1 a1.sinks = k1 a1.channels = c1 該配置檔案中 配置了一個代理a1   在代理agent中配置了一個source(源)一個sink(接收器)和一個channel(通道),分別為:r1,k1,c1 # Describe/configure the so

史上最全web.xml配置檔案元素

一、web.xml配置檔案常用元素及其意義預覽 1 <web-app> 2 3 <!--定義了WEB應用的名字--> 4 <display-name></display-name>