Google Compute Engine have tight security features in place for VM instances. They do not let outside connections to VM instances unless you configure them. This is why we had to generate and add our own SSH key pair to GCP console. We’re now going to login to GCP VM instance with a SSH key file we created in earlier tutorial.
Login in to a GCP VM instance with a SSH key file is actually an easy task. We’re going to use software called Putty. This should be already installed on your PC, if you followed my tutorial to generate SSH key pair. The MSI installer you downloaded should have installed it. If you don’t have it installed for whatever reason, you can install it from Putty utilities.
Configure Putty to use SSH Key file
Click Browse and select the private key file from your computer. I instructed you to save the private key file on a secure location. Now it’s time to use it.
Configure auto login to VM Instance with Putty
Type your VM instance username as Auto-login username. This was also created when generating SSH key pair. I set it to vpsfix, remember?
Login to GCP VM Instance with a SSH Key File
You’re now getting closer to login to your VM instance. You’ll need the IP address of your VM instance. The external IP address to be exact. You can get it from your GCP VM instances dashboard. Once you have it with you, go to Session from Putty category tree.
Type your VM instance IP address under Hostname and make sure port is set to 22 and SSH is selected as connection type. Now give your session a name under Saved Sessions and then click Save. Your session will now appear in the box below. Simply double-click it to login to your VM instance.
Login to VM Instance root Account
After you login to GCP VM instance with a SSH key file, you should change to root user account. Although your current user have sudo permissions, my tutorials always assume you’re executing command as the root user. Unless stated otherwise. Following command will log you into root account of your VM instance.