zoukankan      html  css  js  c++  java
  • Setup FTP Server On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

    setsebool allow_ftpd_full_access on
    setsebool -P ftp_home_dir on

    vsftpd (Very Secure File Transport Protocol Daemon) is a secure, fast FTP server for Unix/Linux systems. In this how-to article, let us see how to setup a basic FTP server using vsftpd on CentOS 6.5. This procedure will also work on all RHEL CentOS, Scientific Linux 6.x versions.

    My testbox server hostname and IP Address are server.unixmen.local and 192.168.1.101/24 respectively. Change the values as per your scenario.

    Install vsftpd

    All commands should be run with ‘root’ user. Run the following command in terminal to install vsftpd package:

    # yum install vsftpd ftp -y

    Configure vsftpd

    Edit vsftpd configuration file /etc/vsftpd/vsftpd.conf,

    # vi /etc/vsftpd/vsftpd.conf

    Find the following lines and make the changes as shown below:

     [...]
    ## Set to "NO" ##
    anonymous_enable=NO
    
    ## Uncomment ##
    ascii_upload_enable=YES
    ascii_download_enable=YES
    
    ## Uncomment - Enter your Welcome message - This is optional ##
    ftpd_banner=Welcome to UNIXMEN FTP service.
    
    ## Add at the end of this  file ##
    use_localtime=YES

    Start the vsftpd service and make it to start automatically on every reboot:

    # service vsftpd start
    # chkconfig vsftpd on

    Create FTP users

    By default, root user is not allowed to login to ftp server for security purpose. So let us create a testing user called“sk” with password “centos”:

    # useradd sk
    # passwd sk
    

    Connecting to FTP server

    Now let us try to connect to FTP server itself with user “sk”:

    # ftp 192.168.1.101
    Connected to 192.168.1.101 (192.168.1.101).
    220 Welcome to UNIXMEN FTP service.
    Name (192.168.1.101:root): sk
    331 Please specify the password.
    Password:
    500 OOPS: cannot change directory:/home/sk
    Login failed.
    ftp> 

    Probably you will get an error like “500 OOPS: cannot change directory”.

    This is because your SELinux restricts the user to log in to ftp server. So let us update the SELinux boolean values for FTP service:

    # setsebool -P ftp_home_dir on

    Now try again to login to FTP server:

    # ftp 192.168.1.101
    Connected to 192.168.1.101 (192.168.1.101).
    220 Welcome to UNIXMEN FTP service.
    Name (192.168.1.101:root): sk
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> 
    

    Now you will be able to login to FTP server without any problems.

    Client side configuration

    Let me try to log in to the FTP server from my Ubuntu client system.

    $ ftp 192.168.1.101
    ftp: connect: No route to host
    ftp>

    You might see the above error like “ftp:connect:No route to host”. To resolve this error, allow the default ftp port“21″ through your firewall or router. In the server side, do the following.

    Edit file /etc/sysconfig/iptables,

    # vi /etc/sysconfig/iptables

    Add the following lines.

    [...]
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
    [...]

    Save and exit the file. Restart iptables now:

    # service iptables restart

    Now try again from the client system to login to FTP server:

    $ ftp 192.168.1.101
    Connected to 192.168.1.101.
    220 Welcome to UNIXMEN FTP service.
    Name (192.168.1.101:sk): sk
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> 

    Boom!! It’s working now.

  • 相关阅读:
    oracle 判断字符串是否包含指定内容
    java 如何使用多线程调用类的静态方法?
    oracle 快速复制表结构、表数据
    oracle 清空表数据的2种方式及速度比较
    一、Instrument之Core Animation工具
    net登录积分(每天登录积分仅仅能加一次) 时间的比較
    正规方程 Normal Equation
    笑谈贝叶斯网络(干货)上
    SQL SERVER 面试题
    好的创始人想要改变世界,最好的创始人还要不放弃——扎克伯格清华中文演讲
  • 原文地址:https://www.cnblogs.com/ytjjyy/p/4092136.html
Copyright © 2011-2022 走看看