Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 536
Bira Avatar asked Sep 14 '17 10:09

Bira


2 Answers

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

like image 195
Bira Avatar answered Sep 24 '22 19:09

Bira


Yes, It is possible to host an FTP server on Google Cloud. In fact, I wrote an in-depth blog about How to set up an FTP server on Google Cloud.

If your VM is base on Linux then you have to use an application like vsftpd to set up an FTP server.

Here are the steps:

Step 1: Deploy a Virtual Instance on Google Cloud
Step 2: Open SSH terminal
Step 3: Installing VSFTPD
Step 4: Create a User
Step 5: Configure vsftpd.conf file
Step 6: Preparing an FTP Directory
Step 7: FTP/S or FTP over SSL setup (optional)
Step 8: Opening Ports in Google Cloud Firewall
Step 9: Test and Connect

like image 27
Akash Patra Avatar answered Sep 25 '22 19:09

Akash Patra