This method only works  if password login is enabled on the instance.
This may be the case if:
- You set a password during instance creation using custom scripts
- You configured a password for a user account after creating the instance.
Step 1: log in to the instance console
-
1
Navigate to Compute > Instances.
-
2
Click the instance name.
-
3
Open the Console tab.
-
4
Log in using the username and password configured on the instance.
Step 2: Add a new SSH key
-
1
Navigate to the SSH directory.
mkdir -p ~/.ssh
cd ~/.ssh
-
2
Edit the authorized_keys file.
nano authorized_keys
-
3
Paste your new public key into the file.
Example format:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...
-
4
Save the file and exit the editor.
Step 3: Set the correct permissions
Ensure the SSH directory and key file permissions are secure.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Step 4: Connect using the new key
You can now connect to your instance using your new private key.
Follow the steps to connect to cloud instances via SSH.