Centos7 ftp環境搭建,centos7ftp搭建

來源:互聯網
上載者:User

Centos7 ftp環境搭建,centos7ftp搭建

  沒玩過linux,折騰了半天的ftp,好不容易親測通過了。不容易啊。

  作業環境:vm虛擬機器 centos7

  首先:搞定網路問題;預設情況下使用ifconfig可以看到虛擬機器下是無網路的。(註:虛擬機器網路設定為NAT或橋接模式都是可以的)

   

  輸入命令nmtui 開啟網路設定

  斷行符號-》斷行符號

  

  

  將倒數第二項 Automatically connect 勾上 然後就有網路了

  

  

  然後更新系統:yum update

  查看vsftpd是否已安裝:vsftpd -v  (預設都是沒安裝的)

  安裝vsftpd:yum install vsftpd

  然後  y y y......

 

  安裝完成後配置防火牆(firewall)

  firewall-cmd --permanent --add-service=ftp

  firewall-cmd --add-port=21/tcp

  firewall-cmd --reload

  

  配置vsftpd: vi /etc/vsftpd/vsftpd.conf  

  

  開啟並設定以下配置:

  anonymous_enable=NO (修改) 

  chroot_local_user=YES (取消注釋)(此項為限定使用者訪問目錄為目前的目錄)

  

  然後最底部設定並添加:

 

  pam_service_name=vsftpd

  userlist_enable=YES

  tcp_wrappers=YES

 

  listen_port=21

  data_connection_timeout=12

  guest_enable=YES

  guest_username=ftpuser (ftp的使用者名稱,多個使用者可重複這一行並修改使用者名稱)

  user_config_dir=/usr/website(使用者訪問的檔案夾)

  pasv_enable=YES

  virtual_use_local_privs=YES

  pasv_min_port=10060

  pasv_max_port=10090

  accept_timeout=5

  connect_timeout=1

  allow_writeable_chroot=YES (解決串連是提示500 OOPS:vsftpd:refusing to run with writable root inside chroot() 的問題)

  退出並儲存:wq

  重啟vsftpd:

    systemctl restart vsftpd.service

    相關命令:systemctl start vsftpd.service

         systemctl status vsftpd.service

 

  建立檔案夾: mkdir /usr/website

  建立使用者:

    useradd -g root -M -d /usr/website -s /sbin/nologin ftpuser

  設定密碼:

    passwd ftpuser

  檔案夾授權:

    chown -R ftpuser.root /usr/website

  

  到目前為止,還有最後一個問題:selinux (不設定的情況下ftp提示:553 Could not create file)

  搗鼓了半天都沒配置成功。最後嘗試了兩個方案。

  一、關閉selinux;

    vi /etc/selinux/config

    設定 SELINUX=Disabled

    重啟系統。

  二、將selinux改成permissive(寬容模式)

    命令:setenforce 0

 

然後,可以試試看了。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.