Script filling password from command line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script filling password from command line
# 1  
Old 01-09-2012
Script filling password from command line

I have this command that i am calling from php (exec()):


Code:
openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12


and then i need to insert password twice

Enter Export Password:

Verifying - Enter Export Password:


I need script that will fill the password inputs,because exec() will only do that command, but not insert password twice. Do you have any idea how should i do it?
# 2  
Old 01-09-2012
You may be able to do it with popen:

Code:
$f=popen("openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12", "w");

fwrite($f, "password\n");
fwrite($f, "password\n");
pclose($f);

If that doesn't work, it may be demanding a terminal for password inputs, which would make automating it extremely difficult.
# 3  
Old 01-09-2012
How about setting an environment variable with the password (eg putenv("INPASS=secret"); )
and using the -passin env: option of openssl -passin env:INPASS
# 4  
Old 01-11-2012
Any other process on the system may be able to read that password in transit when you put it in the environment, though it's not as obvious as making it a parameter.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[bash] script is filling up my /var/log

I am trying to create a script that checks if my VPN connection is up and running... Everything seems to work as except but for some reason, the script fills up my /var/log/auth.log with the below information Dec 13 01:07:44 debian sudo: soichiro : TTY=pts/0 ; PWD=/home/soichiro/Desktop ;... (5 Replies)
Discussion started by: soichiro
5 Replies

2. Shell Programming and Scripting

Need one line command to create and set password for new user...

Using useradd abc --password password (5 Replies)
Discussion started by: Jagruti Rml
5 Replies

3. Shell Programming and Scripting

how to run a command line with another user without prompts for password

Hi, I'm writing a script, in the script I need to use tcpdump to capture some packets however it needs root priviledge my computer is configured by school and I have no real root priviledge so I can't use sudo on my computer,like Code: sudo tcpdump ...... I have to use a limited... (1 Reply)
Discussion started by: esolve
1 Replies

4. Shell Programming and Scripting

FTP command line username and password passing

Dear All, I am new to unix and I am trying to build a shell script which will connect to a different server by passing username and password from a file or command line but not manually... In short I dont want to connect to a diff server via ftp interactively. Any suggestion...looking... (8 Replies)
Discussion started by: Pratik4891
8 Replies

5. Shell Programming and Scripting

Filling out Web Form from Script

I am trying to fill out a web form from within a script I am writing. I think that I should be using curl to do this, but I'm not really sure. The form has username and password fields and a submit button. I want to be able to log in from the command line. Html from the site: <h5... (2 Replies)
Discussion started by: vockleya
2 Replies

6. UNIX for Advanced & Expert Users

How to use SFTP from command line without entering user and password

I would like to use SFTP from command line without entering userid and password. Here is what I have gathered and did. 1) Create a public and private key pair for the protocol you want to use. To create a key pair for use by SSH2, enter: ssh-keygen -t dsa I did that and got... (7 Replies)
Discussion started by: Hangman2
7 Replies

7. UNIX for Advanced & Expert Users

diff command filling /var filesystem space

Hi, I am using diff command to check difference between two files.Both files are very big and when i execute this command /var temp space is filled up almost 99%. Can any one please tell me is there any way i can specify directory name which has more space so that diff can use that dir for... (2 Replies)
Discussion started by: ukatru
2 Replies

8. Shell Programming and Scripting

simple script to alert of archive logs filling

Hi all. I am not a DBA. But I do have responsibility for making sure the archive logs dont fill up and cause the database. This happend the other day while I was absent (sick) and I got a good ticking off for it. Needless to say I dont want this happen! Could anyone lend a hand to a... (8 Replies)
Discussion started by: Incremental
8 Replies

9. UNIX for Dummies Questions & Answers

SSH with a --password command line???

Has anyone heard of an OpenSSH client being compiled with an additional command-line option for password input? I realize there are reasons to NOT do this, and I realize you can achieve the same type of thing with keys, but I am specifically looking to pass the username & password BOTH on the... (5 Replies)
Discussion started by: jjinno
5 Replies

10. Shell Programming and Scripting

Filling in characters to line a file up

Hi there, Ive got a feeling this is quite complex but I have a Comma delimited file which is being transfered up to a mainframe and I have to get every column lining up , I need to add in characters to line it up (but different characters and in different positions based on what field/column it... (1 Reply)
Discussion started by: hcclnoodles
1 Replies
Login or Register to Ask a Question