Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update user's password? #80

Open
larrybg opened this issue Oct 20, 2022 · 1 comment
Open

How to update user's password? #80

larrybg opened this issue Oct 20, 2022 · 1 comment

Comments

@larrybg
Copy link

larrybg commented Oct 20, 2022

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();
```
@larrybg
Copy link
Author

larrybg commented Mar 28, 2023

I have resolved it by adding this:
const sudoWithPsw = echo ${admin_user_password} | sudo -S;

The only problem is that when I'm changing the user's password it appears as a clear text in the /var/log/auth.log file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant