SSH to Google Compute Engine
Introduction
I previously wrote a guide on creating a Virtual Machine (VM) instance on Google Cloud and accessing it via gcloud. However, if your Google Cloud account lacks permission to manage VM instances, or if you want to create a VM instance that allows SSH for easy sharing with other users and compatibility with various SSH tools, follow the steps below.Configure SSH access for VM instance
Firstly, you need to create a compute instance as follows:Next, SSH into this VM to perform the necessary configurations.
Typically, a Google VM instance will have a Distributor ID of Debian. Use the following command to check this before proceeding with the next steps.
Next, set the password for the root account as follows:
Next, use the Vim editor to change the settings in the sshd_config file.
Find and change the following fields to the following values:
If you're not familiar with using the Vim editor, you can use the following commands to edit the `sshd_config` file:
- `i`: Switch to interactive mode (allows editing)
- `Esc`: Switch to normal mode (allows using commands)
- `:wq`: Write then quit (saves and closes the file)
After successfully updating the configuration, restart the service.
SSH to a VM Instance
First, you need to obtain the External IP of the VM instance.
To SSH into the VM instance, use the following command:
After entering your password, the SSH connection will be successful.
You can also use SSH tools or file managers like WinSCP, PuTTY, or Remmina, depending on your needs. These tools make it easy to work with your VM and allow you to save your SSH info for future connections.
Feel free to leave your thoughts in the comments, and don’t forget to like, share, and follow for more great content!
Comments
Post a Comment