Skip to content

How to update user's password? #80

@larrybg

Description

@larrybg

How to update user's password using simple-ssh? The passwd command requires password confirmation. Do I have to provide in: option twice? This doesn't work... Here is what I have right now:

ssh
     .exec(`echo PASSWORD | sudo -S useradd -m -c "${firstName} ${lastName}" -s /bin/rbash ${userID}`, {
                    pty: true,
                    out: function (stdout) {
                        console.log(stdout);
                    },
                    err: function (stderr) {
                        return reject(stderr);
                    }
                })
                .exec(`echo PASSWORD | sudo -S passwd ${userID}`, {
                    pty: true,
                    // HOW TO CONFIRM USER'S PASSWORD?
                    // SEND 2 PARAMETERS?
                    in: rndPassword,
                    in: rndPassword,
                    out: function (stdout) {
                        console.log(stdout);
                    },
                    err: function (stderr) {
                        return reject(stderr);
                    }
                })
                .on('error', function (err) {
                    logger.error(err);
                    ssh.end();
                    return reject(err);
                })
                .start();
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions