Google Cloud FTP and SFTP Setup: The Definitive Guide [2019]

Share on facebook
Share on twitter

Do you want to transfer files from your computer (PC) to Google Cloud Instances ?  Then don’t worry I am here to help you.

In this tutorial you will learn How to upload and download files from Windows or Mac PC to Google Cloud Instances via SFTP.

How to transfer File to Google Cloud Instances?

The first obstacle you’ll face after setting up a VM instance is how to transfer files to your Google Cloud VM. It is very obvious, because google cloud does not have any shiny option on their dashboard. The basic transfer option is hidden in SSH section of your VM Instances.

Here is a picture of it. This basic option,  will  frustrate you, it is slow  and annoying. 

Other than the basic option there are three ways which you can follow to transfer files to Google Cloud.

First, using Google Cloud SDK Tools. But that said this option is worse than before, for a newbie. You have to execute command to transfer a simple file.

Second, using FTP (File Transfer Protocol), but Google Cloud  VM instance does not come with a pre-installed FTP server, so you have to set up an FTP server, in order to connect to Google Cloud using FTP. Here is a blog of mine which help you to Set up an FTP server on GCP.

Third, using SFTP (SSH File Transfer Protocol) which we are going to discuss in the blog. SFTP is more secure than FTP and because Google Cloud instance came with SSH, you don’t need to install anything on your VM instance to transfer files using SFTP.

So In this blog I am going to show you how you can transfer files to Google Cloud using FTP / SFTP client like Filezilla, Winscp, Cyberduck, etc  on your PC (Window or macOS).

What is different between FTP and SFTP?

FTP stands for “File Transfer Protocol”. And SFTP stands for “SSH File Transfer Protocol” OR “Secure File Transfer Protocol”.

The main disadvantage of using FTP protocol is security. FTP uses two separate channels, both of which are unencrypted, this means that the information from either of the channel can be intercepted and accessed.

SFTP ensures that data is securely transferred using a private and safe data stream.

It is wise to not have a huge security loop hole in your server, that is why you should use only SFTP rather than Ftp. And by the way Google Cloud does give a click ready ftp setup option.

What is Public and Private keys.

To set up Sftp you need to generate SSH keys pair. These keys pair will help you to encrypt and decrypt data.

Public key: You will add or copy this key to your Google Cloud Metadata. This key will encrypt data which can then only be read by the person who holds the corresponding private key.

Private key: This key file should only remains within your PC. Only a user in possession of a private key that corresponds to the public key at the server will be able to authenticate successfully.

What is Filezilla?

FileZilla is a free software, cross-platform FTP / SFTP application, Two different version of it is available one is Filezilla client and another Filezilla server.

You will be using Filezilla client in this tutorial.

Filezilla client is available for Windows and macOS.

What is Winscr?

WinSCP (Windows Secure Copy) is a free and open-source SFTP, FTP, WebDAV, Amazon S3 and SCP client for Microsoft Windows. Its main function is secure file transfer between a local and a remote computer. Beyond this, WinSCP offers basic file manager and file synchronization functionality. 

It is not available for macOS.

If you are a windows’ user, then I recommend you to use Winscp.

What is Cyberduck?

Cyberduck is widely used by the macOS user. It  is an open-source client for FTP and SFTP, WebDAV, and cloud storage (OpenStack Swift, Amazon S3, Backblaze B2 and Microsoft Azure), available for macOS and Windows (as of version 4.0) licensed under the GPL.

For Windows PC:

If you are a windows user then the easiest way to generate RSA keys is through PuttyGen. Yes you can generate  public and private key with other application e.g.. Google SDK etc.

If  you already setup SSH clients like PuTTy ,Google Cloud SDK  then you don’t need to generate new keys. You can use your old public and private keys.

Generate public and private Keys

To generate Public and private RSA key follow these steps below:

  1. Download and install PuTTy.
  2. Generate Public and private keys using Puttygen.
  3. Add Public key to Google Cloud.
    • Use one public key for only one VM Instances
      OR
    • Use one public key for all the VM Instances.

1. Download and install PuTTy.

Firstly, you need to do is to download Putty. HERE is the link to Download putty.

Next Step is to install putty on your computer.

2. Generate Public and private keys using Puttygen.

Now click on your window button. Then search and open PuTTYgen to generate Public and Private keys.

Click on “generate” and move your mouse to create public and private keys.

I recommended you  to change the key comment field to something recognizable and easy to type, as this will become a user name later!

Save the private key. Later, This private key will be needed to configure putty.

Copy the Public key

I recommended you to also save the public key by clicking on “Save public key” button. 

Join Us

Facebook

Twitter

YouTube

Want Exclusive Tutorials?

3. Add Public key to Google Cloud.

After your SSH key Files have been generated, You have to add your SSH public key file in your Google Cloud Project or Instances Metadata section.

You can use one SSH keys pair for all the available VM Instances or one SSH keys pair for only one Instances.

3.1 Use one public key for only one Vm Instances

To add SSH Public key to only a specific VM Instances follow the steps below.

Click on the hamburger menu in the upper left-hand corner of your Google Cloud Platform dashboard.

After that navigate to Compute Engine >> VM Instances.

Open the setting section by clicking over the name of your VM instance.

Here I am running a Debian 9.9 WordPress server. It does not matter what you are running.

Click on the edit Button.

After that scroll down and click on the “Show and edit” Button.

You need to paste the Public key which you copied earlier from the puttygen application.

3.2 Use one public key for all Vm Instances

To use one  SSH Public key for all of your VM Instances follow the steps below.

In these steps you will learn how to add an SSH key to Project Metadata.

Login to your Google cloud console. After that from the hamburger menu in the upper left-hand corner of your Google Cloud Platform dashboard, navigate to Compute Engine >> Metadata >> SSH keys.

After that Click on Add item and Paste the  Public key which you copied from the puttygen application. Then  click on the save button.

The metadata public key will work for all the VM instances. You do not need to add to change keys for every VM instances.

Google Cloud Sftp setup with Filezilla.

To set up Filezilla client on your windows PC follow the steps below.

Those are Steps for this tutorial.

  1. Download and Install Filezilla.
  2. Configure Filezilla.
  3. Connect to Google Cloud.
  4. Troubleshooting: Can not upload or edit files.

1. Download and Install Filezilla.

Goto the link below and download a suitable version of filezilla application for your 64bit or 32 bit windows pc.

DOWNLOAD: Filezilla Client.
After you download the filezilla client run it on your windows PC.

2. Configure Filezilla.

After you installed Filezilla Client, Open it and navigate to Edit >> Settings.

Then Click on SFTP. After that click on Add key file. And select the private key file which you saved from PuttyGen. Click on “OK” button to save the settings.

Now navigate to File >> Site Manager.

After that click on New Site  and give a name. Then click on the Protocol and choose “SFTP – SSH File Transfer Protocol.


Copy your External IP and place it on the Host Section (step 3 in this image).

In the username field, type your PuTTyGen key comment.

Then click on OK button to save the setting.

3. Connect to Google Cloud.

To access your VM Instances files navigate to File >> Site Manager. Then click on Connect button.

Here what look like when  you’ve connected successfully.

4. Troubleshooting: Can not upload or edit files.

If you are seeing this error below

Error /...  : open for write:permission denied

Error File transfer failed

It means that you don’t have a proper permission to modify or upload your files. You have to change the file or folder permission to 777. Click here to know how to change the permission.

Google Cloud Sftp setup with Winscp.

Here are the steps to set up Winscp FTP/ Sftp Client on your Google Cloud VM Instances.

  1. Download and install Winscp.
  2. Configure Winscp
  3. Transfer file to Google Cloud.
  4. Troubleshooting : Can’t  upload or modify files and folders on winscp.

Firstly, Download Winscp. Here the link to download Winscp

Next, install Winscp on your windows pc.

After you have installed successfully, open the Winscp.

A login setup field will pop up if not then navigate to.

Firstly, Click on the “Advances” . Then navigate to SSH >> Authentication. After that on the Private key file field select the public key which you generated from PuTTyGen. Next Click on OK.



Secondly, Choose the SFTP from the File Protocol dropdown menu.

Thirdly, Type the External IP Address of your VM Instances in the Host name field.

Fourthly, Place your puttygen key comment in the User name field.

After all those steps click on Login.

If you have successfully connected then you can see a screen like the above image.

When you are trying to upload or modify something and an error popup like the above image.

Error,

Permission denied.
Error code: 3
Error message from server: Permission denied.

It means that you don’t have proper access permission on that files or folders.
You have to change the permissions. Click here to know how to change the permission.




Google Cloud Sftp setup with Cyberduck.

Open the that link here and download Cyberduck Application.

Then Install Cyberduck on your windows PC.

Click on the Open Connection button on your upper left-hand corner.

To configure Cyberduck follows the steps below,

1st step: Select the SFTP from the drop down menu.

2nd step: Type the external IP Address of your VM Instances in the SERVER field.

3rd step: Type your puttygen key comment in the username field.

4th steps: Click on Choose. And select the private key which you generated from puttygen.

5th step: Click on Connect button.

Click on allow to connect via Sftp.

If you have successfully connected with Cyberduck , you can see a  screen like this.

Permission denied. Please contact your web hosting service provider for assistance.

41 OPENDIR
42 READDIR
43 READDIR
44 CLOSE
45 OPEN

If you saw a error like the above , It means that you have to change file or folder permission to access it. Click here to know how to change the permission.




For Mac Os:

Generate Public and Private key

To transfer files to your Google Cloud Instances, You have to generate Public and private SSH key files. In Mac, you don’t need any fancy 3rd party application to generate SSH keys because Mac OS Support SSH naively.

You have to execute some command using your mac default terminal.
That’s all.

If you already have SSH Keys pair you can use that too!

Note: If you followed our “SSH into Google Cloud: The Definitive Guide [2019]” tutorial, then your SSH key pair may stored in ~/.ssh folder. For some reason filezilla can’t access hidden files. So you have to move or generate new SSH files.

Execute this command to move files.

mv ~/.ssh/is_rsa ~/Desktop
mv ~/.ssh/is_rsa.pub ~/Desktop

Or change the .ssh to ssh by executing this command.

mv ~/.ssh ~/ssh

Generate SSH key pair:

On your Mac OS , navigate to Go >> Utilities >> Applications >> Terminal.

Execute that command below to generate public and private keys.

ssh-keygen -t rsa -C give-a-name -f ~/Desktop/id_rsa

-t rsa = To generate RSA keys.

-C ****** = It is your user-name.

-f ~/Desktop/id_rsa = “-f ” command is to store those file in a particular directory. Here I  want to store those SSH keys pair in Desktop folder as id_rsa (names of the ssh key file).

Execute that command below to copy the public key.

pbcopy < ~/Desktop/id_rsa.pub

Add Public key to Google Cloud.

After your SSH key Files have been generated, You have to add your SSH public key file in your Google Cloud Project or Instances Metadata section.

You can use one SSH keys pair for all the available VM Instances or one SSH keys pair for only one Instances.

Use one public key for only one Vm Instances

To add SSH Public key to only a specific VM Instances follow the steps below.

Click on the hamburger menu in the upper left-hand corner of your Google Cloud Platform dashboard.

After that navigate to Compute Engine >> VM Instances

Open the setting section by clicking over the name of your VM instance.

Here I am running a Debian 9.9 WordPress server. It does not matter what you are running.

Click on the edit Button.

After that scroll down and click on the “Show and edit” Button.

You need to paste the Public key which you copied by executing pbcopy command.

After that click on save.

3.2 Use one public key for all Vm Instances

To use one  SSH Public key for all of your VM Instances follow the steps below.

In these steps you will learn how to add an SSH key to Project Metadata.

Login to your Google cloud console. After that from the hamburger menu in the upper left-hand corner of your Google Cloud Platform dashboard, navigate to Compute Engine >> Metadata >> SSH keys.

After that Click on Add item and Paste the  Public key which you copied by executing pbcopy command in mac terminal. Then  click on the save button.

The metadata public key will work for all the VM instances. You do not need to add to change keys for every VM instances.

Google Cloud Sftp setup with Filezilla.

To set up Filezilla Client on your Mac OS, you have downloaded it.

Open that link here on your browser and download Filezilla Client for you mac.

After that install Filezilla Client on your Mac Os.

Open the filezilla on your Mac PC. Then navigate to Edit >> Settings.. .

After that click on SFTP, Then click on Add key file.

Next, Select the id_rsa (private key file) file and then click open.

Click on the OK button to save the settings.

After that navigate to File >> Site Manager.

Follow the steps below to configure Site manager in filezilla.

First step: Click on new site and give a name.

Second Step: Choose SFTP from the Protocol drop down menu.

Third Step: Open your Google Cloud Dashboard then navigate to Compute Engine >> VM Instances and copy you External IP Address. After that paste it on the Host field. 

Fourth step: Type the user name.  (-C  *****).

Fifth step: Click on Connect button.

After clicking on connect button, an Unknown host key popup will show up, just click on the ok button. 

Here what looks like after you successfully connected to google cloud platform using Filezilla.

If you see “Permission Denied “or “Could not start transfer” type of error while files transfer. This means you don’t have proper permission to modify those files. You have change the permission to 777. Click here to know how to change the permission.

Google Cloud Sftp setup with Cyberduck.

Download: Cyberduck

Open the above link on your web browser and download Cyberduck. Then Install it on your Mac.

To configure Cyberduck on Man, Click on Open Connect on the left hand upper corner.

Choose  SFTP (SSH File Transfer Protocol) from the drop down menu.

After that type the external IP Address of your Google Cloud VM.

Then TYPE the user name  (-C  *****) in the Username Field.

Next, Click on the SSH PRIVATE key and  Select the private key file.

Finally, click on Connect button.

Click On  Allow Button to Connect via SFTP.

Here what looks like after you have successfully connected.

Upload Failed

Permission denied. Please contact your web hosting service provider for assistance.

If you saw an error like the above, It means that you have to change file or folder permission to access it. Click here to know  how to change the permission.

Troubleshooting: Can not upload or edit files.

If your permission get denied when you are trying to upload or edit a file, then surely I can help you.

Basically, these problems arrived because of “Linux user and group permissions”. 

If  you want a quick solution then just change the file or folder permission using chmod  command (click here), it will fix your problem.

But if you want to learn in-depth or better solutions for this problem, then read this blog –

3 Ways to Solve Sftp or Ftp “Permission denied” on Google Cloud

How to change file or folder permission on google cloud?

Login to your Google Cloud console account, after that navigate to VM Instances.

Then Click on SSH button.

If you want to edit or modify only a file then execute this command below:

sudo chmod 777 /your-file-location

If you want to change all the files permission(within a directory) then execute this command below:

sudo chmod -R 777 /the-location of the directory /

This will solve the permmision denied problem.

Now it is your time!

I tried my best to provide you a complete tutorial on FTP / SFTP for you Google Cloud. I hope you liked it.

If you need help just drop a comment.

If you benefited from this tutorial, and would like to support my work, please like my Facebook page.

Thanks,

If you like our content, please consider buying us a coffee. Thank you for your support!

2 thoughts on “Google Cloud FTP and SFTP Setup: The Definitive Guide [2019]”

    1. If it is Apple Mac then copy and paste the following command into the Terminal window:
      $ defaults write com.apple.finder AppleShowAllFiles -bool true

      $ killall Finder

Leave a Comment

Your email address will not be published. Required fields are marked *