Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing a linux users password [closed]

Tags:

linux

I'd like to execute a command on a remote vm that creates a user and specifies their password.

using sshpass, I can remotely execute commands as root, e.g.

sshpass -p "rootpasswd" ssh root@remotevm '<remote command here>'

So I want to create a user, which I can do with

adduser <username>

Next I want to use usermod to create a password:

usermod --password <encrypted_pass> <user>

I want to be able to specify the password bananas - so how can I encrypt the string bananas so that I can specify bananas as the encrypted password for the user?

like image 598
stack user Avatar asked Feb 10 '23 02:02

stack user


2 Answers

As root, you can set a password for the user:

passwd username
like image 146
kondareddy Avatar answered Feb 11 '23 14:02

kondareddy


Try chpasswd:

echo "user:password_here" | chpasswd
like image 22
Joe Young Avatar answered Feb 11 '23 14:02

Joe Young