1832345 Members
2470 Online
110041 Solutions
New Discussion

Re: Change password

 
SOLVED
Go to solution
Gustavo Souza Lima
Frequent Advisor

Change password

I created a script to change the password of an user.
I'm using usermod.sam -p "[password]" [username], the command doesn't return error but when I try to login the message "Acces Denied" appears. If I change the password using passwd [username] command and then I try to login everything is OK.

Does Anyone know what's happenning???
5 REPLIES 5
Patrick Wallek
Honored Contributor
Solution

Re: Change password

When using 'usermod.sam' the password supplied to the '-p' string MUST be the encrypted password. usermod.sam does NOT encrypt the password for you, it just writes the string to the appropriate area.

James R. Ferguson
Acclaimed Contributor

Re: Change password

Hi:

Here's a simple Perl script to generate an encrypted password that you can use:

# cat .pwgen
#!/usr/bin/perl -l
die "One arg expected\n" unless @ARGV;
print crypt(
$ARGV[0],
join( '',
( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' )[ rand 64, rand 64 ] )
);
1;

...run as:

# ./pwgen plaintext

The script's output is your corresponding encrypted password.

Regards!

...JRF...
Gustavo Souza Lima
Frequent Advisor

Re: Change password

Okay...and how can I do that?!?!

Can you help, please??
Patrick Wallek
Honored Contributor

Re: Change password

Use JRF's script to encrypt the password.

You could do it all on one command line by doing:

usermod.sam -p $(./pwgen plaintext) userid

Where "plaintext" is the unencrypted password you want.
James R. Ferguson
Acclaimed Contributor

Re: Change password

Hi (again):

> Okay...and how can I do that?!?!

If byt "that" you mean generate an encrypted password from a plaintext one, suitable for using with Sam, use my prior posted script.

Regards!

...JRF...