溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

基于本地用戶的vsftpd搭建

發(fā)布時間:2020-07-24 10:19:09 來源:網(wǎng)絡(luò) 閱讀:431 作者:390892467 欄目:移動開發(fā)

要求:

   一、禁止匿名賬號和系統(tǒng)賬號登錄FTP服務(wù)器

   二、普通賬號被禁錮在家目錄

   三、開啟指定用戶能切換到其他目錄

   四、設(shè)置系統(tǒng)登錄日志記錄

1、安裝

#yum install vsftpd lftp -y
#rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-2.2.2
/usr/share/doc/vsftpd-2.2.2/AUDIT
/usr/share/doc/vsftpd-2.2.2/BENCHMARKS
/usr/share/doc/vsftpd-2.2.2/BUGS
/usr/share/doc/vsftpd-2.2.2/COPYING
/usr/share/doc/vsftpd-2.2.2/Changelog
/usr/share/doc/vsftpd-2.2.2/EXAMPLE
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-2.2.2/FAQ
/usr/share/doc/vsftpd-2.2.2/INSTALL
/usr/share/doc/vsftpd-2.2.2/LICENSE
/usr/share/doc/vsftpd-2.2.2/README
/usr/share/doc/vsftpd-2.2.2/README.security
/usr/share/doc/vsftpd-2.2.2/REWARD
/usr/share/doc/vsftpd-2.2.2/SECURITY
/usr/share/doc/vsftpd-2.2.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-2.2.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-2.2.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-2.2.2/SECURITY/TRUST
/usr/share/doc/vsftpd-2.2.2/SIZE
/usr/share/doc/vsftpd-2.2.2/SPEED
/usr/share/doc/vsftpd-2.2.2/TODO
/usr/share/doc/vsftpd-2.2.2/TUNING
/usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub

2、配置


#sed '{/^#/d;/^$/d}' /etc/vsftpd/vsftpd.conf
anonymous_enable=NO                             #設(shè)定不讓匿名登錄
local_enable=YES                                #指定在/etc/passwd內(nèi)的賬號才能以真實用戶登錄
write_enable=YES                                #允許用戶上傳文件與目錄
local_umask=022                                 #建立新目錄755和文件644權(quán)限     
dirmessage_enable=YES                           #若目錄下有.message則會顯示其中的內(nèi)容
connect_from_port_20=NO                         #支持主動式聯(lián)機(jī)功能
xferlog_enable=YES                              #啟動登錄文件記錄,記錄于/var/log/xferlog
dual_log_enable=YES                             #啟用獨立日志功能
vsftpd_log_file=/var/log/vsftpd.log             #ftp訪問日志位置
xferlog_file=/var/log/xferlog                   #登錄日志位置
xferlog_std_format=YES                          #支持wuftp日志格式,可以使用wuftp登錄文件的分析軟件
chroot_list_enable=YES                          #啟用chroot禁錮用戶列表模式,和下項配合使用
chroot_list_file=/etc/vsftpd/chroot_list        #如果為YES,設(shè)定不被chroot用戶列表
chroot_local_user=YES                           #限制默認(rèn)用戶chroot
pasv_enable=YES                                 #支持?jǐn)?shù)據(jù)流的被動連接模式
pasv_min_port=40000                             #被動連接模式支持的
pasv_max_port=40080                             端口范圍
pasv_promiscuous=YES                            #禁用pasv檢查
listen=YES                                      #獨立進(jìn)程啟動
listen_port=10090                               #使用命令通道端口,服務(wù)器偵聽端口
pam_service_name=/etc/pam.d/vsftpd              #pam模塊名稱
userlist_enable=YES                             #開啟userlist機(jī)制管理登錄賬號
userlist_deny=YES                               #默認(rèn)YES,拒絕列表
userlist_file=/etc/vsftpd/user_list             #列表位置
tcp_wrappers=YES                                #支持tcp wrappers的防火墻機(jī)制
max_clients=10                                  #最多支持10個用戶的連接
max_per_ip=50                                   并且一個用戶最多50的連接

3、新建測試賬號


#useradd nagios
#echo 'nagios' | passwd --stdin nagios
Changing password for user nagios.
passwd: all authentication tokens updated successfully.

4、不受chroot控制的用戶

#cat /etc/vsftpd/chroot_list
nagios

5、測試

#lftp -p 10090 -u nagios,nagios ServerIP
#lftp nagios@192.168.100.10:~> ls
-rw-r--r--    1 501      501          1578 May 05 03:41 passwd
-rw-r--r--    1 501      501           220 May 05 03:41 rc.localcheng
lftp nagios@ServerIP:~cd /etc/
cd ok, cwd=/etc
lftp nagios@ServerIP:/etc> pwd

逃離Home成功

6、一般用戶測試

# lftp -p 10090 -u cytxmanager,centos ServerIP
lftp cytxmanager@ServerIP:~> ls
-rw-r--r--    1 500      500          1578 May 05 03:14 passwd
lftp cytxmanager@ServerIP:/> cd /etc/
cd: Access failed: 550 Failed to change directory. (/etc)

被chroot

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI