日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

centos7下 vsftpd初使用

發布時間:2025/7/14 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7下 vsftpd初使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一. 安裝

1. 命令: yum -y install vsftpd

2. 創建一個用戶專門用來登錄vsftpd

#在根目錄下創建一個文件夾ftpfile

mkdir ftpfile?

#創建用戶ftpuser, 該用戶主目錄名為ftpfile ?-s為該用戶所用的shell, 此處表示不登錄,既沒有ssh功能

useradd ftpuser -d /ftpfile -s /sbin/nologin?

# -R表示遞歸處理 用戶名:用戶組 該句意思是將ftpfile整個文件夾的擁有者改成ftpuser

chown -R ftpuser:ftpuser /ftpfile/

?#更改用戶密碼

passwd ftpuser

?

二. 修改配置

默認配置文件為/etc/vsftpd/vsftpd.conf, 也可以通過whereis vsftpd查找

在這個配置基礎上進行修改,添加即可

?

# Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=NO # # Uncomment this to allow local users to log in. # When SELinux is enforcing check for SE bool ftp_home_dir local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. # When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # Activate logging of uploads/downloads. xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/xferlog # # If you want, you can have your log file in standard ftpd xferlog format. # Note that the default log file location is /var/log/xferlog in this case. xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: ftpd_banner=Welcome to blah FTP service. #local_root=/ftpfile use_localtime=yes # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) chroot_local_user=NO chroot_list_enable=YES # (default follows) chroot_list_file=/etc/vsftpd/chroot_list allow_writeable_chroot=YES # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=NO # # This directive enables listening on IPv6 sockets. By default, listening # on the IPv6 "any" address (::) will accept connections from both IPv6 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 # sockets. If you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. # Make sure, that one of the listen options is commented !! listen_ipv6=YESpam_service_name=vsftpd userlist_enable=YES userlist_deny=YES userlist_file=/etc/vsftpd/user_list tcp_wrappers=YESpasv_min_port=61001 pasv_max_port=62000

?然后在/etc/vsftpd/chroot_user文件中添加 ftpuser

作用: 此份配置是允許ftpuser用戶登錄, 并且將其限制在主目錄下,對于user_list文件沒有修改過

user_list以及ftpusers里的用戶被禁止登錄, 因為userlist_enable=YES, userlist_deny=YES

ftpusers里的用戶本身就被vsftpd所禁止登錄

  

三. 關鍵配置解釋

anonymous_enable=NO?#禁止匿名訪問

ftpd_banner=Welcome to blah FTP service. ?#歡迎信息

local_root=/ftpfile ? ?#指定根目錄文件夾, 如果注釋掉, 則根目錄文件夾為用戶的主目錄

use_localtime=YES #使用本地時間

?


?

userlist_enable, userlist_deny, userlist_file=/etc/vsftpd/user_list

說清楚這三個屬性,必須談到/etc/vsftpd下面的ftpusers, user_list文件

ftpusers文件中的用戶是被禁止登陸到ftp服務器的, 就相當于一個黑名單, 里面存放的是權限很大的用戶, 為了安全考慮,vsftpd不想要權限過大的用戶登錄進來

以免會下載上傳一些危險文件破壞系統, 例外這個文件始終是有效的,與任何配置項都是無關的

user_list的有效性卻是與userlist_enable, userlist_deny兩個屬性有關, 它的作用可以是一個白名單,也可以是一個黑名單。具體要根據

userlist_enable, userlist_deny來決定

注:以下所談不包括ftpusers名單的用戶, 因為ftpusers名單里的用戶永遠是被禁止登錄的

1. userlist_enable=YES, userlist_deny才起作用, 決定是否啟用user_list名單

2. userlist_enable=YES && userlist_deny=YES時, user_list名單里的用戶不允許登錄, 黑名單作用

當嘗試用名單里的用戶登錄時, 不會出現密碼選項,直接報530 Permission denied. Login failed.錯誤

3.?userlist_enable=YES &&?userlist_deny=NO,??user_list名單里的用戶允許登錄, 起白名單作用,?user_list名單外的用戶不允許登錄

當嘗試用名單外的用戶登錄時, 不會出現密碼選項,直接報530 Permission denied. Login failed.錯誤

4. userlist_enable=NO, user_list名單不起作用

?


?

chroot_local_user,chroot_list_enable,chroot_list_file=/etc/vsftpd/chroot_list,allow_writeable_chroot=YES

chroot_local_user:是否將所有用戶限制在主目錄, 即不能跳出主目錄外(YES:限制, NO:不限制)?

chroot_list:/etc/vsftpd下的一個文件, 作用相當于一個例外表, 即不受chroot_local_user限制

chroot_list_enable: 是否開啟chroot_list名單(YES/NO)

allow_writeable_chroot:是否允許chroot_list名單里的用戶具有寫操作(YES/NO)

1.?chroot_list_enable=NO,?chroot_list名單不起作用, 取決于chroot_local_user的值

2. chroot_list_enable=YES &&?chroot_local_user=YES

意思是將所有用戶限制在主目錄內,但是chroot_list名單里的用戶除外, 即不限制

3.?chroot_list_enable=YES &&?chroot_local_user=NO

意思是不限制用戶在主目錄內,但是chroot_list名單里的用戶除外, 即chroot_list名單里的用戶被限制在主目錄內

4.?allow_writeable_chroot=YES 一般設置成YES, 不然用戶主目錄如果擁有寫權限時, 登錄會報錯的

當然要想擁有寫操作, 用戶主目錄必須擁有寫權限以及allow_writeable_chroot=YES

?


?

pasv_min_port=61001

pasv_max_port=62000 ?#指定上傳下載使用端口, vsftpd默認會使用端口,但是線上需要開放具體防火墻端口, 故自己指定

?

四. 開啟vsftpd服務

systemctl start vsftpd ?#開啟服務

systemctl restart vsftpd #重啟服務, 修改了配置需要重啟才生效

systemctl stop vsftpd ?#關閉服務

systemctl enable vsftpd ?#開機自啟動

?

五. 訪問vsftpd(需要開放防火墻)

1. 瀏覽器 ?ftp://ip

2. 命令 ?ftp ip

3. 客戶端軟件 ?winscp等客戶端軟件

?

轉載于:https://www.cnblogs.com/wt20/p/8305748.html

總結

以上是生活随笔為你收集整理的centos7下 vsftpd初使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。