passwd on a simple script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passwd on a simple script
# 1  
Old 09-09-2010
passwd on a simple script

hi guys

I am working on a script which is basically a menu for some linux operators...
I need on this menu for the operators the option to change the password...
This are 2 linux servers using Linux heartbeat.

what I need is to change change the password using passwd command and replica that change to the secondary server....

I've been trying to capture the output of passwd command to implement my script but I have not been able to do it and to reflect the new password on the other server still I don't have any idea.... I tried dsh (commands on multiples server but it did not work)

thanks a lot
# 2  
Old 09-09-2010
"passwd" is designed not to be intercepted for pretty obvious reasons. Instead of trying to capture its input, try duplicating changes made to /etc/passwd or /etc/shadow.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 09-09-2010
Quote:
Originally Posted by Corona688
"passwd" is designed not to be intercepted for pretty obvious reasons. Instead of trying to capture its input, try duplicating changes made to /etc/passwd or /etc/shadow.

got your point

in that case when the user changes his password on node01 I should use a scp o rsync to the node02 to sync password on both nodes?

but how could I scp/rsync passwd - shadow file when a normal user can not overwrite those...
# 4  
Old 09-09-2010
Unless you configure sudo to allow you, you can't. Duplicating passwords in any of these ways is of course dangerous -- any bug in your code could become an exploit, or lock you out. LDAP or NIS might be better ways to share passwords, but take a bit of work to get going.

You can also do some trickery with ssh and expect. expect is sufficiently tricky to fool interactive commands into believing it's an interactive terminal but using it opens you up to the security pitfalls terminal-only behavior was supposed to prevent.

Even then I wouldn't try intercepting the input to 'passwd' as much as capture the new password into my own script, then feed it into passwd both locally and remotely.

Last edited by Corona688; 09-09-2010 at 04:27 PM..
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 09-09-2010
chpasswd(8) might help. I agree with Corona688 - avoid scp/rsyncing /etc/passwd or /etc/shadow directly.
This User Gave Thanks to frank_rizzo For This Post:
# 6  
Old 09-09-2010
Quote:
Originally Posted by frank_rizzo
chpasswd(8) might help. I agree with Corona688 - avoid scp/rsyncing /etc/passwd or /etc/shadow directly.
I just added passwd in the script I am creating and it request the password successfully but I'm still have no idea to sync the password with the other server

As far I know chpasswd command only takes plain text...
# 7  
Old 09-09-2010
Quote:
Originally Posted by karlochacon
As far I know chpasswd command only takes plain text...
please read the man page.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

2. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies

3. Shell Programming and Scripting

Need script to monitor change in /etc/passwd

Hi All, From Audit point of view, I need to add a script to my production Solaris servers. That should be able to mail me, if any user is added or removed. That means, I should get a mail, what user is deleted or added in /etc/passwd, i.e. if there is a change in this file, I should be... (8 Replies)
Discussion started by: solaris_1977
8 Replies

4. Solaris

Solaris passwd script

Hello all, Since Solaris passwd does not have --stdin option can you advise how to change the password for 30 users with a script. The password can be the same one. I`ve tried already echoing, xargs, cat and similar. Thanks. ---------- Post updated at 04:04 AM ---------- Previous update... (0 Replies)
Discussion started by: click
0 Replies

5. Shell Programming and Scripting

Modify /etc/passwd via script

We have a business need to modify the /etc/passwd file every time a new user gets added, because the user ID begins with a zero. When you create the new user in smit, even if you put the leading zero in, it does not retain it when the entry is added. That being said, I need to create a script... (11 Replies)
Discussion started by: mshilling
11 Replies

6. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

7. Shell Programming and Scripting

passing passwd to a command in a script

Hi All, I have a requirment.. I need to pass a registry password to a command.. Actually when the command executed in the script, it will return some warnings first, then after it'll ask password like below, $ cleartool rmtag -vob -all <vob_name> Warnings: ------------------ Registry... (3 Replies)
Discussion started by: raghu.iv85
3 Replies

8. Shell Programming and Scripting

passwd in shell script

Is there a way to change user password using passwd command in shell script? I don't want to use expect. Please help (8 Replies)
Discussion started by: corny
8 Replies

9. UNIX for Advanced & Expert Users

setting passwd in script

HP-UX 11 I currently have a script that is running useradd and passwd commands to automate setting up new users. It was originally designed so that passwd was run with -d -f to delete a passwd and force user to set passwd at next login. Now mgmt wants instead to set a first-time passwd and have... (2 Replies)
Discussion started by: LisaS
2 Replies

10. Shell Programming and Scripting

passwd -l script

I need to lockout about 250 user accounts on a server. I figure on putting the user accounts to be locked out in a text file and the running a script to go through the file and run the "passwd -l useraccount" against the /etc/passwd file (yes, I am root as I do this). Here is what I have so... (3 Replies)
Discussion started by: antalexi
3 Replies
Login or Register to Ask a Question