To connect to a Google Cloud Platform (GCP) Compute Engine instance using SSH and Termius, you will need to follow these steps:
ssh-keygen -t rsa -f ~/.ssh/KEY_FILENAME -C USERNAME -b 2048
KEY_FILENAME: This is the name of the SSH key pair. You can use any name you want, but it is recommended that you use a name that is unique to the Compute Engine instance you are connecting to.
USERNAME: This is the username you want to use to log in to the Compute Engine instance.
The default location for the SSH key pair is ~/.ssh. If you would like to change the location, you can use the -d option.
The default size for the SSH key pair is 2048 bits. If you would like to change the size, you can use the -b option.
- Copy the public key to the clipboard by running the following command:
- Navigate to the "Metadata" section of the Compute Engine instance in the GCP Console.
- Click the "Edit" button.
- Click the "SSH Keys" tab.
- Click the "Add Item" button.
- Paste the public key into the "Key" field.
- Click the "Save" button.
- Open Termius on your local machine.
- In the Termius dashboard, click the "Add Host" button.
In the "Add Host" window, enter the following information:
- Address: This should be the external IP address of your Compute Engine instance. You can find the external IP address in the GCP Console by navigating to the "Networking" section and clicking on the "External IP addresses" tab.
- Port: The default SSH port is 22, so you can leave this field set to 22 unless you have changed the default port for your instance.
- Username: This should be the username you want to use to log in to the Compute Engine instance.
- Set a Key: Use the private key from ssh key we generated previously.
Click the "Save" button in the "Add Host" window.
Click the "Connect" button next to the host you just created.
You should now be connected to the Compute Engine instance.
Note: If you are having trouble connecting to your Compute Engine instance, make sure that the firewall rules for the instance allow incoming connections on port 22 (the default SSH port) and that the instance has a public IP address. You can also check the logs for the instance in the GCP Console to see if there are any error messages that can help troubleshoot the issue.