- Create instance
- Create ssh key for remote host access locally:
ssh-keygen -t rsa -C {host_username}
- Add ssh public keys to
.ssh/authorized_keys
on the host side - 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:
- 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}
- Attach created tag to an instance:
gcloud compute instances add-tags {instance_name} --tags allow-tcp-{desired_port}
- 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
https://gist.github.com/embarq/127d94882f0647449a4802ee2906d639