Skip to content

Instantly share code, notes, and snippets.

@embarq
Last active November 29, 2019 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save embarq/c767cb503588214f3d693a949ef71188 to your computer and use it in GitHub Desktop.
Save embarq/c767cb503588214f3d693a949ef71188 to your computer and use it in GitHub Desktop.
Remote development with VSCode & GCloud Compute Engine

Set up GCloud Compute Instance

  1. Create instance
  2. Create ssh key for remote host access locally: ssh-keygen -t rsa -C {host_username}
  3. Add ssh public keys to .ssh/authorized_keys on the host side
  4. Connect to host via ssh {host_username}@{host_ip}

If you want to use a specific port for local preview it needs to be available by setting up a firewall rule:

  1. Create new rule for a tag:
gcloud compute firewall-rules create rule-allow-tcp-{desired_port} --source-ranges 0.0.0.0/0 --target-tags allow-tcp-{desired_port} --allow tcp:{desired_port}
  1. Attach created tag to an instance:
gcloud compute instances add-tags {instance_name} --tags allow-tcp-{desired_port}
  1. Example
gcloud compute firewall-rules create rule-allow-tcp-8080 --source-ranges 0.0.0.0/0 --target-tags allow-tcp-8080 --allow tcp:8080

gcloud compute instances add-tags instance-1 --tags allow-tcp-8080

gcloud compute firewall-rules list
@embarq
Copy link
Author

embarq commented Nov 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment