passwd on a simple script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passwd on a simple script
# 8  
Old 09-09-2010
Quote:
Originally Posted by frank_rizzo
please read the man page.
still don't see how

I mean I already used passwd as normally used to set the password but now it¿s only changed on node01....cannot find a way to replicate the change on node02
Smilie
# 9  
Old 09-09-2010
Quote:
Originally Posted by karlochacon
still don't see how
You must log into the other system and run chpasswd. Do you have ssh access?
# 10  
Old 09-09-2010
Quote:
Originally Posted by Corona688
You must log into the other system and run chpasswd. Do you have ssh access?
yes I have ssh

what I mean is this

Code:
ssh $SERVER 'echo "root:123456" | chpasswd'

but instead of using a plain text as you see in the example below is there a way send the encrypted password on /etc/shadow????

This is because I already requested on the menu to change password after that should be something to sync both password same user
# 11  
Old 09-09-2010
Quote:
Originally Posted by kopper
but instead of using a plain text as you see in the example below is there a way send the encrypted password on /etc/shadow????

This is because I already requested on the menu to change password after that should be something to sync both password same user
don't change the password like that because it will show up in the process list. Here are the quick high level steps that should work for you.

Step 1 - create a file with one user per line in this format

user1:plain_text_pw
user2:plain_text_pw
userN:plain_text_pw

Step 2 - copy this file to each system(scp using public key auth would work great for automation)

Step 3 - run the chpasswd command on each system(run remotely via ssh public key auth)

run it this way so no passwords are displayed in ps. make sure to put the data file in a secure location that root can only access
Code:
chpasswd </path/to/your/file


Depending on the version of your chpasswd command it may be able to handle encrypted passwords in the data file. Check the man page. If it does support it an easy way would be to change the password on one system, grab the hash from /etc/shadow and then use that for the password value in the data file. Of course make sure you use the right option for encryption used. In most cases it will be md5.

hope this helps.
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