- Published on
Connect Compute Engine - VM instances Google Cloud
- Authors
- Name
- Surya Harahap
- @suryaharahap18
Connecting to a Google Cloud VM instance is an important aspect of managing and utilizing cloud resources effectively. Whether you're a developer, systems administrator, or cloud enthusiast, understanding the various methods for connecting to your VM instances can simplify your workflow and increase your productivity. In this blog, i show to connect remote server google cloud - VM instance with VSCode.
Step 1 :
Step 2:
Generate SSH key pair. You can check this google docs here OR you can follow step this
#your home directory
$ ssh-keygen -t rsa -f ~/.ssh/mywebserver -C suryaharahap18@gmail.com -b 2048
Step 3:
Add public SSH key in VM instance - Google Cloud. You can follow this step by step
$ cd .ssh
$ cat mywebserver.pub #copy public key
Copy paste public key in VM instance
- Select name instance
Edit VM instances
In Security and access, you can add item (number 1 in image) SSH keys and paste public key in this column (number 2 in image )
Step 4:
Configure SSH Hosts
in the keyboard (macOS) select CMD + shift + p > Remote-SSH: Connect to Host
Select Configure SSH Hosts…
Select /Users/surya/.ssh/config
And following this config
Host ecs-user
HostName 8.219.41.49 #IP address from VM instance Google CLoud
User root
IdentityFile ~/.ssh/mywebserver #location file generate ssh keys
Step 5:
Connect to host by terminal
ssh -i .ssh/mywebserver username_instance@35.198.223.99
Connect to host by VSCode editor
In the keyboard (macOS) select CMD + shift + p > Remote-SSH: Connect to Host… and select you name server instance
And now you can view vscode connect remote server VM instance - Google Cloud 🙌🏻