行業資訊

  • 首頁
  • 新聞中心
  • 行業資訊

Ubuntu16.04 ftp服務器安裝+配置


2021年01月12日

ftp服務器安裝與配置


1. ftp服務端的安裝

如果之前配置過ftp服務器的還是之后配置的服務器,無法啟動服務,那么基本是配置出現了錯誤,那么可先完全卸載后再進行安裝。如果無法定位多半是鏡像源的問題,請更換阿里源。


 
  1.  
    sudo apt-get update
  2.  
    sudo apt-get install vsftpd
  3.  
    vsftpd --version //檢測是否安裝
2. ftp服務端的配置
 vim /etc/vsftpd.conf    //編輯配置文件

修改vsftpd.conf文件如下:


 
  1.  
    listen=NO //是否開啟監聽ipv4和ipv6數據
  2.  
    listen_ipv6=YES //是否開啟監聽ipv6數據
  3.  
     
  4.  
    # Allow anonymous FTP? (Disabled by default).
  5.  
    anonymous_enable=NO //是否允許匿名登陸,無需密碼
  6.  
     
  7.  
    # Uncomment this to allow local users to log in.
  8.  
    local_enable=YES //是否允許本地用戶登錄
  9.  
     
  10.  
    # Uncomment this to enable any form of FTP write command.
  11.  
    write_enable=YES //是否允許登陸者上傳文件
  12.  
     
  13.  
    # Default umask for local users is 077. You may wish to change this to 022,
  14.  
    # if your users expect that (022 is used by most other ftpd's)
  15.  
    local_umask=022 //設置本地用戶默認要減免的權限
  16.  
     
  17.  
    # Activate directory messages - messages given to remote users when they
  18.  
    # go into a certain directory.
  19.  
    dirmessage_enable=YES //目錄消息,能夠給遠程登陸的用戶發送目錄
  20.  
    #
  21.  
    # If enabled, vsftpd will display directory listings with the time
  22.  
    # in your local time zone. The default is to display GMT. The
  23.  
    # times returned by the MDTM FTP command are also affected by this
  24.  
    # option.
  25.  
    use_localtime=YES //服務器所展示的目錄將隨著本地時間而改變
  26.  
    #
  27.  
    # Activate logging of uploads/downloads.
  28.  
    xferlog_enable=YES //開啟上傳下載的日志記錄
  29.  
    #
  30.  
    # Make sure PORT transfer connections originate from port 20 (ftp-data).
  31.  
    connect_from_port_20=YES //確認連接傳輸的端口號為20
  32.  
     
  33.  
    # You may override where the log file goes if you like. The default is shown
  34.  
    # below.
  35.  
    xferlog_file=/var/log/vsftpd.log //日志文件存放位置
  36.  
    #
  37.  
    # If you want, you can have your log file in standard ftpd xferlog format.
  38.  
    # Note that the default log file location is /var/log/xferlog in this case.
  39.  
    xferlog_std_format=YES //日志文件采用標準格式
  40.  
     
  41.  
     
  42.  
    # You may fully customise the login banner string:
  43.  
    ftpd_banner=Welcome to FTP service. //在使用shell時登陸那么會發送歡迎語
  44.  
     
  45.  
     
  46.  
    # You may specify an explicit list of local users to chroot() to their home
  47.  
    # directory. If chroot_local_user is YES, then this list becomes a list of
  48.  
    # users to NOT chroot().
  49.  
    # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
  50.  
    # the user does not have write access to the top level directory within the
  51.  
    # chroot)
  52.  
    chroot_local_user=YES //對本地用戶是否實施限制
  53.  
    chroot_list_enable=YES //開啟限制白名單
  54.  
    # (default follows)
  55.  
    chroot_list_file=/etc/vsftpd.chroot_list //白名單路徑,若無這個文件需要自己創建
  56.  
     
  57.  
    # This option should be the name of a directory which is empty. Also, the
  58.  
    # directory should not be writable by the ftp user. This directory is used
  59.  
    # as a secure chroot() jail at times vsftpd does not require filesystem
  60.  
    # access.
  61.  
    secure_chroot_dir=/var/run/vsftpd/empty
  62.  
    #
  63.  
    # This string is the name of the PAM service vsftpd will use.
  64.  
    # pam_service_name=vsftpd
  65.  
    pam_service_name=ftp //此處ubuntu的系統需要改為ftp
  66.  
     
  67.  
    # This option specifies the location of the RSA certificate to use for SSL
  68.  
    # encrypted connections.
  69.  
    rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
  70.  
    rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
  71.  
    ssl_enable=NO
  72.  
     
  73.  
    #
  74.  
    # Uncomment this to indicate that vsftpd use a utf8 filesystem.
  75.  
    utf8_filesystem=YES //編碼統一為utf8編碼,可以識別中文,防止亂碼
 3. vftpd配置完成

添加設置ftpuser用戶和訪問目錄


 1. 創建ftp用戶組和用戶

 
  1.  
    sudo groupadd ftpusers //創建ftpusers用戶組
  2.  
    sudo useradd -m ftpuser_lxr//創建一個用戶并且自動創建家目錄為/home/ftpuser_lxr
  3.  
    (第二種方式:mkdir /home/ftpuser_lxr //先創建家目錄sudo userad -d /home/ftpuser_lxr ftpuser_lxr //綁定這個家目錄)
  4.  
    usermod -G ftpusers ftpuser_lxr //將這個新用戶加入到ftpusers用戶組中
  5.  
    sudo passwd ftpuser_lxr //更改密碼
  6.  
    mkdir /home/ftpuser_lxr/ftp //為用戶添加一個具有一定權限的文件夾
  7.  
    chmod 777 -R /home/ftpuser_lxr/ftp //新建一個pub目錄用于存放文件,并且賦予全部權限
  8.  
    usermod -s /sbin/nologin username //限制用戶登錄方式;限制用戶username只能通過ftp登陸,而不能直接登陸服務器
2.將該用戶加入vsftpd.chroot_list白名單中

 
  1.  
    mkdir /etc/vsftpd.chroot_list
  2.  
    vim vsftpd.chroot_list

該文件內容如下:


 
  1.  
    #白名單
  2.  
    ftpuser_lxr
3.開啟并重啟vsftpd的服務

systemctl start vsftpd或者service vsftpd start 
systemctl restart vsftpd或者service vsftpd restart


測試

方法一:

打開瀏覽器,在地址欄輸入:ftp://ip_addresss

方法二:

 在ubuntu中使用shell輸入:ftp ip_address

方法三:

 在windows中在文件管理器地址欄輸入:ftp://ip_addresss,該方式可以上傳下載文件

方法四:

 在windows中使用cmd輸入:ftp://ip_addresss //顯示連接成功

客服
主站蜘蛛池模板: 综合久久国产九一剧情麻豆| 久久综合亚洲鲁鲁五月天| 色视频综合无码一区二区三区| 天天综合网网欲色| 伊人色综合久久天天| 热综合一本伊人久久精品| 色综合久久综合中文综合网| 久久久久青草线蕉综合超碰| 久久婷婷五月综合成人D啪| 伊人久久综合成人网| 综合国产精品第一页| 色欲天天婬色婬香视频综合网| 国产天堂一区二区综合| 国产欧美日韩综合自拍| 五月六月综合欧美网站| 欧美国产综合欧美视频| 色婷婷狠狠久久综合五月| 亚洲国产欧美国产综合一区| 亚洲香蕉网久久综合影视| 一本一道久久a久久精品综合| 色婷婷六月亚洲综合香蕉| 丁香婷婷色五月激情综合深爱| 欧美日韩国产综合视频一区二区二| 欧美日韩国产码高清综合人成| 色综合久久无码五十路人妻| 亚洲成色在线综合网站| 色狠狠色狠狠综合天天| 色综合视频一区二区三区| 亚洲国产成人久久综合碰| 亚洲VA欧美va国产va综合| 亚洲欧洲日产国产综合网| 丁香五月亚洲综合深深爱| 欧美激情综合色综合啪啪五月| 久久综合鬼色88久久精品综合自在自线噜噜| 色综合久久88色综合天天| 亚洲综合成人网在线观看| 人人狠狠综合久久亚洲高清| 久久香综合精品久久伊人| 色五月丁香六月欧美综合| 欧美精品色婷婷五月综合| 香蕉蕉亚亚洲aav综合|