0

Reset a disk root password

by
Published Oct 17, 2025

Resets the password of a Disk you have permission to `read_write`. > --- - __CLI__. ``` linode-cli linodes disk-reset-password \ 123 25674 \ --password aComplex@Password ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` linodes:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Reset a disk root password
7
 * Resets the password of a Disk you have permission to `read_write`.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli linodes disk-reset-password \
19
  123 25674 \
20
  --password aComplex@Password
21
    ```
22

23
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
24

25
- __OAuth scopes__.
26

27
    ```
28
    linodes:read_write
29
    ```
30

31
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
32
 */
33
export async function main(
34
  auth: Linode,
35
  apiVersion: "v4" | "v4beta",
36
  linodeId: string,
37
  diskId: string,
38
  body: { password: string },
39
) {
40
  const url = new URL(
41
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/disks/${diskId}/password`,
42
  );
43

44
  const response = await fetch(url, {
45
    method: "POST",
46
    headers: {
47
      "Content-Type": "application/json",
48
      Authorization: "Bearer " + auth.token,
49
    },
50
    body: JSON.stringify(body),
51
  });
52
  if (!response.ok) {
53
    const text = await response.text();
54
    throw new Error(`${response.status} ${text}`);
55
  }
56
  return await response.json();
57
}
58