
Google Cloud offers a lot of interesting features and makes it very easy for you to get started quickly. I’ve however had a hard time accessing and making changes to my development files as the gcloud command-line tool is not always well documented. Through experimentation and trial & error I managed to find a way to access my development files and gain root permissions to edit them.
Accessing your VM instance
Step 1 – Generate an SSH key pair
To connect to your Linux VM instance you must generate an SSH key pair. An SSH key pair consists of a public SSH key file and a private SSH key file.
Follow those steps to generate a key pair:
- Enter ssh-keygen -t rsa in your terminal
- The ssh keygen utility will prompt you to indicate where to store the key. Edit the path if needed and press enter
- Type in a passphrase
- Your private and public key are generated in the .ssh directory
- Enter the following command in your terminal to copy your public key: cat ~/path-to-your-ssh-directory/id_rsa.pub
- Your public key is copied to your clipboard
Step 2 – Add your public key to your project metadata
- Go to your Google Cloud Platform dashboard
- Open the menu on the left and go to Compute Engine > Metadata
- Go to the 2nd tab “SSH Keys” and click Edit
- Click on Add item and paste your public key in
Your can now connect through SSH or SFTP to your VM instance.
Making changes
SFTP
- Download Filezilla (this is what I use but you can use any other FTP client)
- Open the app
- Go to the Setting page > SFTP
- Click on Add key file…
- Select your private key file
On MacOS, key files are usually located in /Users/{user name}/.ssh. Note however that dot files and dot folders are hidden by default. Make sure to hit “CMD+SHIFT+.“ in the Filezilla finder to make the .ssh folder appear.

Once your private key file is added to Filezilla, click OK and go back to the main interface of the application.
- You can now enter your IP address in the host field (for ex: sftp://0.0.0.0 – 0.0.0.0 being your external IP).
- Write the username that is at the very end of your public key file.
- Do not enter a password
- Write 22 in the port field
- Click connect
You are now connected to your VM instance. To view your development files go to /var/www/html/. Some files may require root permissions to be edited. The only way to get root permission is to connect via SSH.
SSH from the browser
- Go to your VM instance page
- Click on SSH under the Connect column
- A popup will appear
- Enter ssh -i [PATH_TO_PRIVATE_KEY] [USERNAME]@[EXTERNAL_IP]
- Go to /var/www/html (this is where your solution resides)
Here’s what you need to do to become sudo (root):
- Enter “sudo passwd”
- Enter a password
- Enter “su”
- Enter the password you defined in step 1
- You’ve become root
At this point, I would recommend either making changes using the vim editor (basic vim commands) or changing the permissions of the files you want to change to allow edits through SFTP.