ftp服務器安裝與配置


ftp服務器安裝與配置


1. ftp服務端的安裝
  • 1

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

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

修改vsftpd.conf文件如下:

listen=NO                 //是否開啟監聽ipv4和ipv6數據 listen_ipv6=YES //是否開啟監聽ipv6數據 # Allow anonymous FTP? (Disabled by default). anonymous_enable=NO //是否允許匿名登陸,無需密碼 # Uncomment this to allow local users to log in. 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 //設置本地用戶默認要減免的權限 # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES //目錄消息,能夠給遠程登陸的用戶發送目錄 # # If enabled, vsftpd will display directory listings with the time # in your local time zone. The default is to display GMT. The # times returned by the MDTM FTP command are also affected by this # option. use_localtime=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 //確認連接傳輸的端口號為20 # You may override where the log file goes if you like. The default is shown # below. xferlog_file=/var/log/vsftpd.log //日志文件存放位置 # # 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 fully customise the login banner string: ftpd_banner=Welcome to FTP service. //在使用shell時登陸那么會發送歡迎語 # 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=YES //對本地用戶是否實施限制 chroot_list_enable=YES //開啟限制白名單 # (default follows) chroot_list_file=/etc/vsftpd.chroot_list //白名單路徑,若無這個文件需要自己創建 # This option should be the name of a directory which is empty. Also, the # directory should not be writable by the ftp user. This directory is used # as a secure chroot() jail at times vsftpd does not require filesystem # access. secure_chroot_dir=/var/run/vsftpd/empty # # This string is the name of the PAM service vsftpd will use. # pam_service_name=vsftpd pam_service_name=ftp //此處ubuntu的系統需要改為ftp # This option specifies the location of the RSA certificate to use for SSL # encrypted connections. rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=NO # # Uncomment this to indicate that vsftpd use a utf8 filesystem. utf8_filesystem=YES //編碼統一為utf8編碼,可以識別中文,防止亂碼
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
 3. vftpd配置完成
  • 1

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


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

該文件內容如下:

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

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


測試

方法一:

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

方法二:

 在ubuntu中使用shell輸入:ftp ip_address
  • 1

方法三:

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

方法四:

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM