Is there a way to automatically prepopulate a password field?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is there a way to automatically prepopulate a password field?
# 1  
Old 07-31-2006
Is there a way to automatically prepopulate a password field?

I want to know if there is a way that I can right a script that will su to root and prepopulate the password field?
# 2  
Old 07-31-2006
How do you mean "prepopulate"? Do you mean adding the entries in the passwd file? That is taken care of by the passwd program. You do not need to manually add entries in the /etc/passwd file.
# 3  
Old 07-31-2006
Sorry I should have been a little more clearer.

What I mean is suppose I wanted to write a simple script that would run su (username) and would add to the password field automatically without needing to enter it at the password prompt?

Chris
# 4  
Old 07-31-2006
This is from my manual page on 'passwd'. Yours may not have this option. I believe some versions of passwd are intentionally written so that the password must be entered from the keyboard.

Code:
$ man passwd
...
       --stdin
              This  option  is  used  to indicate that passwd should read the new password
              from standard input, which can be a pipe.

# 5  
Old 07-31-2006
Yes there is, but why?
You'd have to store the root passwd in your script, which isn't very secure. You could encrypt it, but then you'll need a passphrase to decrypt it, so a)it defeats your purpose of not typing a passwd or b) encrypted data without a passphrase is as good as ASCII.

You could also use sudo to allow your user access to root commands; that way you don't need to su to root every time you need to do a specific task. Of course, if you allow a user full access, again, not very secure.
# 6  
Old 07-31-2006
On this paticular server root is blocked to every ip but mine and one other. Both trusted,
# 7  
Old 07-31-2006
Ok. I'm not going to lecture you any more on security, so here's one way of doing it with expect:
Code:
#!/usr/local/bin/expect --
spawn su -
expect Password:
send myRootPassword\r
expect myPrompt
interact

Once you type exit, both you'll exit root and the script will die and you'll be back to your regular user.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to automatically enter password in a script?

Hi I'm working with AIX 6.1 I would like to ssh to a server without entering password ( to monitor something) but there's no way to do that by authentication keys, so I need to write a script which can ssh to that server without entering password ( no need to hide passsword in the script, just an... (9 Replies)
Discussion started by: bobochacha29
9 Replies

2. Shell Programming and Scripting

Shell Script to Automatically Read My Password

I have a shell script to run set of commands every week . I dont have a root access on the server but I can run the commands using pbrun cat myscript.sh * * * pbrun command.... each time I run the script , it asks me for my password then it executes fine. ./myscript.sh Password... (7 Replies)
Discussion started by: Sara_84
7 Replies

3. Shell Programming and Scripting

ssh -t answering automatically to the password

hi, i'm using the folowing ssh command to list the newuser "crontab' from myuser ssh -t myuser@host1 "sudo -u newuser crontab -l" this is ok but it is asking me a password. Mot de passe de myuser: The problem is that i want to answer it automatically in a shell script with the... (22 Replies)
Discussion started by: Nicol
22 Replies

4. Shell Programming and Scripting

Script to automatically enter a password

I need to retrieve thousands of lines of information from hundreds of nodes. Each node requires a passowrd in order to retrieve the information. Fortunately, the password is the same for each one of them. So I am trying to come up with a script that would allow me to include the password so I can... (0 Replies)
Discussion started by: Ernst
0 Replies

5. UNIX for Dummies Questions & Answers

how to enter hardcoded password automatically

In the script i am passing a command from script which is called from cron. When this command is called from cron the unix prompt asks for password. Can we automatically enter the password when promted(if the password is hardcoded in script)?? Please let me know how to enter the password... (4 Replies)
Discussion started by: abhi_n123
4 Replies

6. Shell Programming and Scripting

How to enter a password in the script automatically when prompted?

Hi Friends, We need to create a script which will invoke a command with diffrent parameters. The command invoked needs the password. So how automatically we can enter password in the script to the command? example.: #!/bin/ksh for par in `cat parfile` do # Here is the main command... (1 Reply)
Discussion started by: sourabhsharma
1 Replies

7. Shell Programming and Scripting

Change root password automatically

I need to change root password automatically in some servers all three months. I want to run this process in one of the servers and reply it to the others. The password must be known by the administrator. (3 Replies)
Discussion started by: Alrica
3 Replies

8. Shell Programming and Scripting

automatically create password and expand it to other servers

I´m a new system administrator. I have to create a script to put in crontab to change periodically root password and didtribute it to other servers. I searched the posted threads but I didn't find my answer. I would like to do this using ssh and trusted keys. Can anyone help me? Thanks. Aldina (0 Replies)
Discussion started by: Alrica
0 Replies

9. Shell Programming and Scripting

add lines automatically based on a field on another file

hello I have a number of lines that need to be added at the end of a file each time I add a field in another file (let's name it file2) file2 has this format: filed1:field2:path1:path2:path3:path... Whenever I add a path field, I should add to file1 these lines: <Location path1>... (0 Replies)
Discussion started by: melanie_pfefer
0 Replies

10. Shell Programming and Scripting

Script to automatically change password.

I want to write a script which will automatically take password sequentially from a file after every 10 days. i.e the passwd command should be executed automatically every 10 days and it should take the input from the password file sequentially. Has any1 got a solution?????????????? (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question