Operating System - HP-UX
1833832 Members
2168 Online
110063 Solutions
New Discussion

change u_pwd on trusted system using sed

 
SOLVED
Go to solution
Scott Lindstrom_2
Regular Advisor

change u_pwd on trusted system using sed

I have been doing lots of searching, but can't find exactly what I need to do. Like many posts here, I need to remotely change the password in the /tcb structure. I encrypt the password on our admin system, then remsh to each remote system to perform the password change. (This is already in place for our non-trusted systems).

/usr/sam/lbin/usermod.sam seems to be the preferred method, but I can't use this since it requires that the user not be logged on (which sometimes they will be).

A post I found mentioned that it is possible to use sed to change everything between ":pwd=" and the following ":" to another string, but the sed syntax was not posted.

If I have something like:

:u_pwd=qja75J6s6rdu23v1FSp.e9HI:u_auditid#14:\

How could I change the u_pwd field to the encrypted password passed into the script?

TIA,
Scott Lindstrom
4 REPLIES 4
Sanjay_6
Honored Contributor
Solution

Re: change u_pwd on trusted system using sed

Hi Scott,

Try Christian's suggestion.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=68115

Hope this helps.

Regds
Scott Lindstrom_2
Regular Advisor

Re: change u_pwd on trusted system using sed

Sanjay -

I was hoping to be able to change the encrypted password field without needing to know what the old encrypted password was.

(If someone can help me extract out the old password from between 'u_pwd=' and the next ':', then I can make the suggestion listed work).

But I would hope there would be a way to change it without knowing (or caring).

Scott
Scott Lindstrom_2
Regular Advisor

Re: change u_pwd on trusted system using sed

Sanjay -

Looks like I misread the response you referred to. Let me look deeper!

Scott
Scott Lindstrom_2
Regular Advisor

Re: change u_pwd on trusted system using sed

Took a few tries, but this works:

initial_char=`echo $user | awk '{print substr($1,1,1)}'`

cp /tcb/files/auth/$initial_char/$user /tcb/files/auth/$initial_char/$user.bak

sed -e 's/:u_pwd=.*:/:u_pwd='"$newpass"':/' /tcb/files/auth/$initial_char/$user.bak

Thanks!