Skip to content

Turn SSH password login on or off

PATCH /api/v2/vps/{id}/ssh-password-login

Turns root password login over SSH on or off on the running VPS. Turn it on to log in with a password after a rebuild with SSH keys. Turn it off to allow SSH keys only. true sets PasswordAuthentication yes and PermitRootLogin yes. false sets PasswordAuthentication no and PermitRootLogin prohibit-password. Root can then still log in with a key. The change runs inside the VPS through the guest agent and restarts its SSH service. The VPS must be running. The response is the setting read back afterwards, with lastOperation.verified.

Authentication: An API key with the scope write:vm. About keys and scopes

Request

Path parameters

idstringrequired
The VPS ID (vps_…).

Body

enabledbooleanrequired
True to allow password login for root. False to allow SSH keys only.

Example

PATCH /api/v2/vps/{id}/ssh-password-login
curl -X PATCH "https://cloud.hostup.se/api/v2/vps/vps_01hxa3b4c5d6e7f8g9h0j1k2m3/ssh-password-login" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"enabled": true
}'

Responses

200 The setting after the change, read back from the VPS.

Response 200
{
"available": true,
"enabled": true,
"reason": null,
"passwordAuthentication": "yes",
"permitRootLogin": "yes",
"source": "effective_sshd_config",
"sshKeysConfigured": true,
"sshKeys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9wZW5BUElFeGFtcGxlS2V5TWF0ZXJpYWwxMjM0 alex@example.com"
],
"actions": {
"canEnable": {
"allowed": false,
"reason": "SSH password login is already enabled."
},
"canDisable": {
"allowed": true,
"reason": null
}
},
"lastOperation": {
"requestedEnabled": true,
"verified": true,
"message": "SSH password login enabled."
}
}
Response fields
availableboolean
True when the setting was read from the running VPS.
enabledboolean or null
True when root can log in over SSH with a password. Null when the setting could not be read or is unclear.
reasonstring or null
Why the setting could not be read, as a sentence you can show. Null when it was read.
passwordAuthenticationstring or null
The PasswordAuthentication value in the SSH server configuration, in lower case.
permitRootLoginstring or null
The PermitRootLogin value in the SSH server configuration, in lower case.
sourcestring
Where the values come from. effective_sshd_config: the running SSH server. config_files: the configuration files. unavailable: nothing could be read. One of effective_sshd_config, config_files, unavailable, unknown.
sshKeysConfiguredboolean
True when SSH keys are stored on the VPS service.
sshKeysarray of string
Public SSH keys stored on the VPS service, the ones installed at setup or rebuild. GET /api/v2/vps/{id}/ssh-access shows the keys that can log in now.
actionsobject
What the caller can do now.
canEnableobject
Whether turning password login on makes sense now. False when it is already on or the setting cannot be read.
allowedboolean
reasonstring or null
codestring or null
A machine-readable code for why the action is blocked.
canDisableobject
Whether turning password login off makes sense now. False when it is already off or the setting cannot be read.
allowedboolean
reasonstring or null
codestring or null
A machine-readable code for why the action is blocked.
lastOperationobject
What this change did.
requestedEnabledboolean
The enabled value you sent.
verifiedboolean
True when the setting read back matches what you asked for.
messagestring or null
A sentence about the result you can show.

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400Invalid request. The response body is an RFC 7807 Problem Details document.
401Unauthorized. Authentication is required.
403Forbidden. The caller lacks a required scope or does not own the resource.
404Not found. The resource does not exist or is not owned by the caller; code is vps_not_found.
409The change could not be made. code is vps_not_ready (setup is not finished) or upstream_failed (the command could not run or failed inside the VPS, for example because it is stopped). detail says why.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502Upstream failure. A dependent provider request failed; the Problem Details code is upstream_failed. Retry later or contact support if the issue persists.