google-cloud-platformgoogle-compute-engine

How to create ftp (vsftpd) in google cloud compute engine?


How to create ftp in google cloud compute engine? I can connect via SFTP without any issues, but my company is using a software to connect via FTP to download a XML file from the server. Unfortunately that software doesn't have SFTP connection facilities.

I saw lots of examples from the internet and to connect via SFTP not FTP.

Any idea's or tutorials ?


Solution

  • I found a way to do this, Please advice is there any risks.

    apt-get install vsftpd libpam-pwdfile

    nano /etc/vsftpd.conf

    And inside the vsftpd.conf config file.

        # vim /etc/vsftpd.conf
    
        listen=YES
        listen_ipv6=NO
        anonymous_enable=NO
        local_enable=YES
        write_enable=YES
        local_umask=022
        nopriv_user=vsftpd
        chroot_local_user=YES
        allow_writeable_chroot=yes
        guest_username=vsftpd
        virtual_use_local_privs=YES
        guest_enable=YES
        user_sub_token=$USER
        local_root=/var/www/$USER
        hide_ids=YES
    
        listen_address=0.0.0.0
        pasv_min_port=12000
        pasv_max_port=12100
        pasv_address=888.888.888.888 # My server IP
        listen_port=211
    

    Remove everything from the file and add these lines instead

    auth required pam_pwdfile.so pwdfile /etc/ftpd.passwd

    account required pam_permit.so

    Create the main user that will be used by the virtual users to authenticate:

    useradd --home /home/vsftpd --gid nogroup -m --shell /bin/false vsftpd

    Once that is done we can create our users/passwords file.

    htpasswd -cd /etc/ftpd.passwd helloftp

    Next, add the directories for the users since vsftpd will not create them automatically.

    mkdir /var/www/helloproject

    chown vsftpd:nogroup /var/www/helloproject

    chmod +w /var/www/helloproject

    Finally, start the vsftp daemon and set it to automatically start on system boot.

    systemctl start vsftpd && systemctl enable vsftpd

    Check the status to make sure the service is started:

    systemctl status vsftpd

        ● vsftpd.service - vsftpd FTP server
        Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled)
        Active: active (running) since Sat 2016-12-03 11:07:30 CST; 23min ago
        Main PID: 5316 (vsftpd)
        CGroup: /system.slice/vsftpd.service
        ├─5316 /usr/sbin/vsftpd /etc/vsftpd.conf
        ├─5455 /usr/sbin/vsftpd /etc/vsftpd.conf
        └─5457 /usr/sbin/vsftpd /etc/vsftpd.conf
    

    Finally add firewall rules to access via cloud.

    Google Cloud Firewall Settings

    enter image description here

    enter image description here

    Later I have changed my IP from 0.0.0.0 for more restriction