Rebuild VM
/projects/:projectId/vms/:vmId/rebuildRebuilds a virtual machine, reinstalling it from a specified image.
This operation is asynchronous and returns a pollable operation id. Poll
GET /v1/projects/{projectId}/operations/{operationId} using the returned
operationId until its status leaves InProgress. A new initial login password is
generated and returned in the response. If sshKeyIds is omitted or empty, the rebuilt VM has
no SSH keys (the previously bound keys are not carried over); otherwise the provided keys become the
effective set for the rebuilt VM. Set deleteBackups to also delete the VM's backups. Existing
port-forwarding rules are left unchanged: when the new image uses a different service port (for
example RDP 3389 vs SSH 22), update the relevant rule separately via the port-forwards endpoints.
CLI warning
If you have connected to this VM before, there will already be a fingerprint in your local known_hosts file. You can think of this fingerprint as a unique identifier of the server. Usually, the fingerprint is automatically recognized when you try to connect to this IP address. After a rebuild, however, the operating system is reinstalled and a new host key is generated, so that fingerprint is no longer valid.
Therefore, when you reconnect after a rebuild, you might get a warning like this:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
...
...
...
Offending ECDSA key in /home/user/.ssh/known_hosts:2
remove with:
ssh-keygen -f "/home/user/.ssh/known_hosts" -R "<203.0.113.1>"
...
...
If you do get a warning like this, remove the old fingerprint from the known_hosts file as explained below. If you do not get a warning like this, you can skip this section.
Remove the existing fingerprint
After a rebuild the old fingerprint will not become valid again: the VM now has a new host key. You can temporarily comment the old entry out, or delete it and accept the new fingerprint on the next connection.
Add a comment
You can leave the fingerprint as a comment while you finish reconnecting. The line Offending ECDSA key in /home/user/.ssh/known_hosts:2 from the warning tells you the line in which your fingerprint is saved in the known_hosts file. In this example the fingerprint is in line 2. Edit the known_hosts file on your local device:
nano ~/.ssh/known_hosts
Add the # in front of your fingerprint in the line from the warning:
|1|lPqnDMjklla23lPqnDMjkllPq9=|lPqnDMjklla233lPqnDMjklla...
#|1|vlQvhfjekla23lPqnDMjklop5E=|343Pfd964BZxg3kfdIEYKLue4...
Once you are done, use CTRL+X to save the file, Y to confirm and ENTER to close the file. After you reconnect and accept the new host key, you can delete both the commented-out old entry and any leftover obsolete fingerprints from the file.
Delete the fingerprint
Alternatively, use the command from the warning to delete the fingerprint from the known_hosts file:
ssh-keygen -f "/home/user/.ssh/known_hosts" -R "<203.0.113.1>"
Replace <203.0.113.1> with the VM's IP address. Now that the fingerprint was removed, connect again with ssh. This time there should only be a warning about host authenticity. Enter yes and the new fingerprint will be saved in the local known_hosts file.
Request
Responses
- 202
- 400
- 404
- 409
The rebuild request was accepted; the VM is being reinstalled in the background.
The request body failed validation.
The project, VM or image was not found.
Another operation is already in progress on this VM. Poll until it clears, then retry.