CentOS7 install vsftpd service

實驗環境:CentOS Linux release 7.3.1611 (Core)html

內核版本:Linux version 3.10.0-514.el7.x86_64linux

1.查看系統自帶的vsftpd軟件包版本服務器

# yum list vsftpd

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.cn99.com
Installed Packages
vsftpd.x86_64 3.0.2-21.el7 @base

2.開始安裝app

# yum install -y vsftpd

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
–> Running transaction check
—> Package vsftpd.x86_64 0:3.0.2-21.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vsftpd x86_64 3.0.2-21.el7 base 169 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 169 k
Installed size: 348 k
Downloading packages:
vsftpd-3.0.2-21.el7.x86_64.rpm | 169 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : vsftpd-3.0.2-21.el7.x86_64 1/1
Verifying : vsftpd-3.0.2-21.el7.x86_64 1/1

Installed:
vsftpd.x86_64 0:3.0.2-21.el7

Complete!

安裝成功!tcp

3.查看vsftpd配置文件目錄ide

# ll /etc/vsftpd/

/etc/vsftpd/vsftpd.conf //主配置文件,核心配置文件
/etc/vsftpd/ftpusers //黑名單,這個裏面的用戶不容許訪問FTP服務器
/etc/vsftpd/user_list //白名單,容許訪問FTP服務器的用戶列表
/etc/vsftpd/vsftpd_conf_migrate.sh //vsftpd操做的一些變量和設置腳本

4.重命名原有vsftpd.conf配置文件測試

# mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak

5.新建vsftpd.conf 並插入下面參數保存並退出日誌

# vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO //拒絕匿名用戶
local_enable=YES //接受本地用戶
write_enable=YES //能夠上傳(全局控制)
local_umask=022 //本地用戶上傳文件的umask
dirmessage_enable=YES //用戶進入一個目次後,是否給出靜態提示。默認YES,默認便可
xferlog_enable=YES //代表將記錄的上傳下載狀況寫在xferlog_file所指定的文件中
connect_from_port_20=YES //FTP PORT主動模式進行數據傳輸時使用20端口(ftp-data)。YES使用,NO不使用。
xferlog_std_format=YES //是否採用標準格式記錄日誌
chroot_local_user=YES //全部的用戶均不能切換到其餘目錄。
chroot_list_enable=YES //全部的用戶均不能切換到其餘目錄
chroot_list_file=/etc/vsftpd/chroot_list //凡是加入vsftpd.chroot_list中的用戶都不受限止,即;能夠瀏覽其主目錄的上級目錄.
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd //虛擬用戶使用PAM認證方式。
userlist_enable=YES //是否啓用vsftpd.user_list文件。
tcp_wrappers=YES //設置vsftpd是否與tcp wrapper相結合來進行主機的訪問控制
allow_writeable_chroot=YES //解決500 OOPS錯誤

注意:請去掉「//」和「後面的文字」不然啓動ftp服務器可能會失敗。orm

6.建立文件chroot_list文件htm

# touch /etc/vsftpd/chroot_list //默認留空

7.啓動ftp服務

# systemctl enable vsftpd.service //設置開機自啓動
# systemctl start vsftpd.service //啓動ftp服務
# ss -antup | grep ftp //查看ftp服務端口
tcp LISTEN 0 32 :::21 :::* users:((「vsftpd」,pid=6354,fd=3))

顯示21端口表示已經啓動成功

8.新建ftp用戶,其中/home/renwole是我本身的ftp目錄,能夠根據須要進行相應更改

# useradd -g ftp -d /home/renwole -s /sbin/nologin renwole

-g //用戶組 指定用戶所屬的附加組
-d //目錄 指定用戶主目錄,若是此目錄不存在,則同時使用-m選項,能夠建立主目錄。
-s /sbin/nologin //指定用戶只能用於ftp登陸,拒絕登陸系統

9.設置ebadu用戶密碼爲「renwoletest123」

# passwd renwole

輸入兩次相同密碼回車設置成功

10.設置防火牆,不然沒法鏈接ftp服務器,固然你也能夠關閉防火牆。

# firewall-cmd –permanent –zone=public –add-service=ftp //將ftp服務器服務加入防火牆
# firewall-cmd –reload //不重啓firewall防火牆使其重載生效

11.設置SELinux:

# getsebool -a | grep ftp
# setsebool -P ftpd_full_access on

vsftpd服務器已經配置安裝完成,如今能夠測試鏈接ftp服務器了。

原文來自:https://www.linuxprobe.com/linux-install-vsftpd.html

相關文章
相關標籤/搜索