Change password with usermod

Change password with usermod

am 10.03.2007 11:42:28 von gamito

Hi,

I'm trying to set a password directly from a script, using usermod, but=
=20
i get an error, i shouldn't get:

#!Bin/bash
groupadd postgres
useradd -g postgres postgres
PASS=3D`mkpasswd secret`
ID=3D`cat /etc/passwd | grep postgres | cut -f3 -d':'`
usermod -p $PASS -u $ID

This gives me:
"usermod: user 502 does not exist"

But the odd thing is that it exists with that uid.

Any ideas ?

Warm Regards,
M=E1rio Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Change password with usermod

am 10.03.2007 11:56:10 von gamito

Of course it isn't

#!Bin/bash

but

#!/bin/bash
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Change password with usermod

am 10.03.2007 12:55:01 von Krzysztof Dubowik

Hi,

Mário Gamito wrote:
> PASS=3D`mkpasswd secret`
> ID=3D`cat /etc/passwd | grep postgres | cut -f3 -d':'`
> usermod -p $PASS -u $ID
>=20
> This gives me:
> "usermod: user 502 does not exist"

usermod needs a login name rather than the userid and you don't need -u
option:

# usermod -p $PASS postgres

However, I usually user chpasswd to change the password from a script, =
so
your script becomes:

# echo postgres:secret | chpasswd

Hope this helps,
Krzysztof

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Change password with usermod

am 10.03.2007 13:05:54 von gamito

Hi,

Thank you for your answer.

> usermod needs a login name rather than the userid and you don't need =
-u
> option:
>=20
> # usermod -p $PASS postgres
I tried that but didn't work for me:
"[root@mail ~]# usermod -p $PASS postgres
usage: usermod [-u uid [-o]] [-g group] [[-a] -G group,...]
[-d home [-m]] [-s shell] [-c comment] [-l new_name]
[-f inactive] [-e expire ] [-p passwd] [-L|-U] name"


> However, I usually user chpasswd to change the password from a script=
, so
> your script becomes:
>=20
> # echo postgres:secret | chpasswd
But this does :)

Thanks a bunch.

Warm Regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Change password with usermod

am 10.03.2007 22:42:07 von Ian Ward Comfort

On Mar 10, 2007, at 3:55 AM, Krzysztof Dubowik wrote:
> However, I usually user chpasswd to change the password from a =20
> script, so your script becomes:
>
> # echo postgres:secret | chpasswd

A better idea is to:

# chpasswd < passfile

where passfile has been created with the contents:

postgres:secret

That prevents your new password from appearing momentarily in the =20
process list during this procedure.

=97IWC

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html