0

I am in the process of moving an application instance from Google Cloud to IONOS. I have taken an image, exported it to a Google Bucket in .vmdk format and imported it as a new image in IONOS to spin up an instance. This has all worked as expected and the application is accessible with all data. However I can not access the SSH as the keys / credentials are not in the image - how can I add the SSH keys to the image in Google Cloud so they transfer to the new server allowing me to access the root files etc?

james
  • 1

1 Answers1

0

Have a look at the documentation Managing SSH keys in metadata:

An SSH key consists of the following files:

  • A public SSH key file that is applied to instance-level metadata or project-wide metadata.
  • A private SSH key file that the user stores on their local devices.

As it was mentioned by @John Hanley, on you local machine you can find SSH keys located at the following paths:

$HOME/.ssh/google_compute_engine – private key
$HOME/.ssh/google_compute_engine.pub – public key

In addition, you're able to create your own SSH keys and add them to your instance:

  1. create SSH keys:

    ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]

    • public key file: ~/.ssh/[KEY_FILENAME].pub
    • private key file: ~/.ssh/[KEY_FILENAME]
  2. add public SSH key to your VM:

    • go to Compute Engine -> VM instances -> click on NAME_OF_YOUR_VM_INSTANCE
    • paste the content of public key (cat ~/.ssh/[KEY_FILENAME].pub) in ssh-keys text-area:

enter image description here

  1. connect to VM instance:

    ssh -i [PATH_TO_SSH_PRIVATE_KEY] username@[EXTERNAL_IP_OF_YOUR_VM_INSTANCE]
    
Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29