Skip to main content

UserPassword

c.UserPassword calls the API's UserPassword group. The password of a user.

Methods​

MethodReturnsPermissionDescription
Update(ctx, hostname, input)*Response[Collection[UserPasswordResult]]user:writeSet the password of a user.

Update​

func (s *UserPasswordService) Update(
ctx context.Context,
hostname string,
input UserPasswordUpdateInput,
) (*Response[Collection[UserPasswordResult]], error)

Set the password of a user.

Sets the password with chpasswd -e, from its hash on standard input. The controller hashes the password, so the job and NATS have only the hash. Each call makes a new hash, so it always reports changed: true. A user that the host does not have is not found. It runs on the Debian family only, and elsewhere reports skipped.

It sends PUT /api/node/{hostname}/user/{name}/password, and needs the permission user:write.

The examples of the method's definition:

Set a password, go run user_password.go update:

resp, err := c.UserPassword.Update(ctx, target, client.UserPasswordUpdateInput{
Name: "osapitest",
Password: "-",
})

Types​

The fields of each type are the properties of its schema in the API's spec.

RowStatus​

What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

A string, one of ok, failed, skipped, timeout.

UserPasswordResult​

FieldTypeDescription
ChangedboolWhether the host changed.
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
NamestringThe user.
StatusRowStatusWhat happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

UserPasswordUpdateInput​

FieldTypeDescription
NamestringThe name of the path. The user, such as alice.
PasswordstringThe new password, which osapi hashes on the controller. A secret: a reference, secret:///, or the value.

Example​

examples/sdk/client/user_password.go runs each example of this page. With no argument, it lists them.