问题
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 ?
回答1:
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.
Later I have changed my IP from 0.0.0.0 for more restriction
回答2:
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
来源:https://stackoverflow.com/questions/46216385/how-to-create-ftp-vsftpd-in-google-cloud-compute-engine