Sponsored Content
Top Forums Shell Programming and Scripting Problem with feeding password while changing to root user Post 302756555 by mhmn on Wednesday 16th of January 2013 05:31:05 AM
Old 01-16-2013
Problem with feeding password while changing to root user

i want to change user to "root" from another user while running a script. how can i automatically feed the password? for example, i want to write a script say "script.sh"... it will first run the command "p" as mhmn user, and then it will change the user to "root" by using "su - root" command. at this point it asks for the password for root. say the password is "blue". i want to feed the p.w. automatically while it asks for it. inside script.sh it will look something like-
Code:
 
#p
#su - root 
(feed p.w. automatically here)
#p


Last edited by Scott; 01-16-2013 at 06:34 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. AIX

changing user password

I have 02 servers: - Linux RHEL AS 3 (server1) - AIX 5.2 (server2) Running the command rsh server2 passwd derje from the server1 to change derje user password on server2, give me this error: 3004-709 Error while changing the password for "derje" Can somebody help me ? (0 Replies)
Discussion started by: mayge
0 Replies

2. HP-UX

Changing root password

I have two unix system A and B with same configuration. I can use remsh from A system login to B system as root, but when I want to change the root password of B system, it ask me the old password, but i forgot it. However, is it possible to change the B system root password? :( Thanks a lot (3 Replies)
Discussion started by: zetadhell
3 Replies

3. Linux

Problem changing user password

Hi all, I'm having an issue resetting an Linux user password. As root, I type 'passwd <username>, enter the new password, but the user is still Access Denied. Can someone assist me in figuring this one out? The box is running "Linux trm62 2.4.21-15.ELsmp #1 SMP Thu Apr 22 00:18:24 EDT 2004... (6 Replies)
Discussion started by: bbbngowc
6 Replies

4. Solaris

Solaris user changing password

i created 1 user . Now its passwd time period get expired. Now how can I set password for that user. Also how can I set a condition such a way that after every 3 months user must change his passwd. (5 Replies)
Discussion started by: ajitkraj
5 Replies

5. Solaris

changing user password as root on LDAP client SOl10/u7

I'm fairly inexperienced with LDAP and DSEE so to build my skills I installed directory server in the global zone of my Sol 10/u7 machine and created a zone to use as a client. For some reason when I try to change a users password as root (in the client zone) with passwd -r ldap I am prompted for... (1 Reply)
Discussion started by: ilikecows
1 Replies

6. UNIX for Dummies Questions & Answers

Permission denied when changing root password after reset

I have a Solaris 10 machine that I didn't know the root password to so I went into single user mode and removed the password from the shadow file and rebooted and I am able to login with no password now. But my problem is that when I try to change the root password from no password to something... (0 Replies)
Discussion started by: darkone_d1_2000
0 Replies

7. Shell Programming and Scripting

Passing password when changing the user account

Hi All, I have one requirment.. I need to change my id to some sudo account in a server.. Actually our username/passwd will be stored in one gip file like below... $cat .a.gz #It's hidden file username passwd $ So I tried the below script to pass the password when i sudo to... (7 Replies)
Discussion started by: raghu.iv85
7 Replies

8. Shell Programming and Scripting

Feeding password in bash script

Hello I am doing some test. In a script I have to call a change password routine ( ldap ) which ask confirmation. This can be done from terminal. Is there a way to do something like this : #!/bin/bash # blabla blabla blabla blabla # changing_password_routine user_name... (2 Replies)
Discussion started by: jcdole
2 Replies

9. AIX

Changing root password

I want to change the root password on an AIX box. What is the best method to do this so i do not get myself locked out. When I do i search the results come up for resetting the password if you are locked out. Thanks (5 Replies)
Discussion started by: fierfek
5 Replies

10. Solaris

Changing the password of a generic user from ILOM

We run Solaris 11. We have a root login constraint that we can login to the root only after doing a su from a generic account called "cloneroot". We somehow misplaced the password for the cloneroot account recently. So, we can't login to root. We have other accounts (eg. oracle) where we can login... (1 Reply)
Discussion started by: jtamminen
1 Replies
PASSMASS(1)						      General Commands Manual						       PASSMASS(1)

NAME
passmass - change password on multiple machines SYNOPSIS
passmass [ host1 host2 host3 ... ] INTRODUCTION
Passmass changes a password on multiple machines. If you have accounts on several machines that do not share password databases, Passmass can help you keep them all in sync. This, in turn, will make it easier to change them more frequently. When Passmass runs, it asks you for the old and new passwords. (If you are changing root passwords and have equivalencing, the old pass- word is not used and may be omitted.) Passmass understands the "usual" conventions. Additional arguments may be used for tuning. They affect all hosts which follow until another argument overrides it. For example, if you are known as "libes" on host1 and host2, but "don" on host3, you would say: passmass host1 host2 -user don host3 Arguments are: -user User whose password will be changed. By default, the current user is used. -rlogin Use rlogin to access host. (default) -slogin Use slogin to access host. -ssh Use ssh to access host. -telnet Use telnet to access host. -program Next argument is a program to run to set the password. Default is "passwd". Other common choices are "yppasswd" and "set passwd" (e.g., VMS hosts). A program name such as "password fred" can be used to create entries for new accounts (when run as root). -prompt Next argument is a prompt suffix pattern. This allows the script to know when the shell is prompting. The default is "# " for root and "% " for non-root accounts. -timeout Next argument is the number of seconds to wait for responses. Default is 30 but some systems can be much slower logging in. -su Next argument is 1 or 0. If 1, you are additionally prompted for a root password which is used to su after logging in. root's password is changed rather than the user's. This is useful for hosts which do not allow root to log in. HOW TO USE
The best way to run Passmass is to put the command in a one-line shell script or alias. Whenever you get a new account on a new machine, add the appropriate arguments to the command. Then run it whenever you want to change your passwords on all the hosts. CAVEATS
Using the same password on multiple hosts carries risks. In particular, if the password can be stolen, then all of your accounts are at risk. Thus, you should not use Passmass in situations where your password is visible, such as across a network which hackers are known to eavesdrop. On the other hand, if you have enough accounts with different passwords, you may end up writing them down somewhere - and that can be a security problem. Funny story: my college roommate had an 11"x13" piece of paper on which he had listed accounts and passwords all across the Internet. This was several years worth of careful work and he carried it with him everywhere he went. Well one day, he forgot to remove it from his jeans, and we found a perfectly blank sheet of paper when we took out the wash the following day! SEE ALSO
"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" by Don Libes, O'Reilly and Associates, January 1995. AUTHOR
Don Libes, National Institute of Standards and Technology 7 October 1993 PASSMASS(1)
All times are GMT -4. The time now is 10:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy