Openssl scripting problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Openssl scripting problem
# 1  
Old 10-07-2016
Openssl scripting problem

im trying to make sure the openssl password does not show up in the output of ps.

so i'm trying to do something like this:

Code:
MAST=yup
echo "U2FsdGVkX19wH9LrQhuRZes45BM9rfiRpdhTCi+gLls=" | openssl <<HERE 2>&1 >/dev/null
aes-128-cbc -a -d -salt -k "${MAST}"
HERE

But this isn't working.. I get the following error:

Code:
error reading input file
error in aes-128-cbc

note, the password stored in the variable MAST will be given by the user. i'm just hardcoding it in this particular example to illustrate my problem.

the way i was doing this because was:

Code:
echo "U2FsdGVkX19wH9LrQhuRZes45BM9rfiRpdhTCi+gLls=" | openssl aes-128-cbc -a -d -salt -k "yup"

but this shows the password in ps, which is what i'm trying to avoid.
# 2  
Old 10-07-2016
Code:
echo some_input | command <<HERE
but_so_is_this
HERE

Get it? Move the second input to the here-doc also.
Juha
This User Gave Thanks to Juha Nurmela For This Post:
# 3  
Old 10-07-2016
It also seems aes-128-cbc is a command line parameter ("cipher command") to openssl, not something it reads from stdin.
This User Gave Thanks to RudiC For This Post:
# 4  
Old 10-07-2016
Have you tried using public/private key authentication?
This User Gave Thanks to gandolf989 For This Post:
# 5  
Old 10-07-2016
Hi,
try this ( -k is quasi deprecated and better to use -pass ) :
Code:
export MAST="yup"
echo "U2FsdGVkX19wH9LrQhuRZes45BM9rfiRpdhTCi+gLls=" | openssl aes-128-cbc -a -d -salt -pass env:MAST

Regards.
This User Gave Thanks to disedorgue For This Post:
# 6  
Old 10-07-2016
Quote:
Originally Posted by disedorgue
Hi,
try this ( -k is quasi deprecated and better to use -pass ) :
Code:
export MAST="yup"
echo "U2FsdGVkX19wH9LrQhuRZes45BM9rfiRpdhTCi+gLls=" | openssl aes-128-cbc -a -d -salt -pass env:MAST

Regards.
thank you. this worked!

i had came here to ask why this command works from the command line:

Code:
echo "U2FsdGVkX19wH9LrQhuRZes45BM9rfiRpdhTCi+gLls=" | openssl aes-128-cbc -a -d -salt -pass file:<( echo -n "yup" )

but not from a script. if run from a script, i get this:

Code:
./myscript.sh: 3: ./myscript.sh: Syntax error: "(" unexpected


Last edited by SkySmart; 10-07-2016 at 12:35 PM..
# 7  
Old 10-07-2016
You are probably running your script in a different shell.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem of encrypt openssl RC4

Hi Guys sorry about post the code in portuguese but now i fix almost parts of code. now i can encryped and decryped the files but have a small problem. When not writte nathing generate automatically a random cypher but after the value of this cypher not appear igual than variable $saved_key. And... (2 Replies)
Discussion started by: Xremix30
2 Replies

2. Solaris

Solaris v Ubuntu using OpenSSL paste problem

Hello, I hope this means something to someone. I have an odd problem that just started happening recently. I am not the system admin, so I don't have full info on any changes to the system lately. Except that I did upgrade OpenSSL to version 1.0.1.c from 1.0.0j. Anyway, I am trying to... (4 Replies)
Discussion started by: jonycp
4 Replies

3. UNIX for Dummies Questions & Answers

openssl dgst cat header problem

I am trying to run an old script to modify an image file with a modified header to bypass the md5 check but it comes up with an error message. The image file is for use on a Expressgate SSD so that I can add sqx files to it. This is a link from where I got the script:-... (3 Replies)
Discussion started by: r1speedyrider
3 Replies

4. Solaris

NRPE Compiling problem with OpenSSL 1.0

I am trying to compile nrpe 2.12 against openssl 1.0 on Solaris 10 however I am getting core dumps for some reason. Anyone know a way to fix this? Here is the output of make: bash-3.00# make all cd ./src/; make ; cd .. gcc -g -fPIC -Wall -O2 -I/usr/local/ssl/include... (0 Replies)
Discussion started by: _JPL_
0 Replies

5. Shell Programming and Scripting

openssl DES3 in scripting

hi, I have this script in python #!/usr/bin/env python from Crypto.Cipher import DES3 def desEncrypt(key, data): d = des4me(key) return d.encrypt(data) def des4me(key): return DES3.new(key, DES3.MODE_ECB) ... (8 Replies)
Discussion started by: kazikamuntu
8 Replies

6. UNIX for Advanced & Expert Users

scripting problem

hI I m very new to unix ,... I m facing an issue I have to search though a list of directorys, find all .gz files which are older than 7 days and delete that ,,, Any one knows a single command to do this .. Thnks in advance BInu (3 Replies)
Discussion started by: msbinu
3 Replies

7. Shell Programming and Scripting

scripting problem

Sorry everyone, i was able to fix it (0 Replies)
Discussion started by: bebop1111116
0 Replies

8. Shell Programming and Scripting

scripting problem

I hv the below script , that is work fine on unix sytem ( ksh ) , but it is not work in my RH system , the script can kill the idle user who have idel for 120 minutes but exclude the user in the exception.lst the error happen when run the statemnt " (( time = $TIMEOU + 1 )) " , could suggest... (3 Replies)
Discussion started by: ust
3 Replies

9. UNIX for Advanced & Expert Users

solaris 9 openssl make problem with ld

i've seen a few posts regarding this issue, and i've tried the resolutions, but i keep running into the same problem. i'm trying to compile OpenSSL with the use of rsaref-2.0 (i'm running through this tutorial... (1 Reply)
Discussion started by: xyyz
1 Replies

10. Shell Programming and Scripting

Scripting problem

I'm hoping one of you scripting experts can help me. I'm trying to find out the IP Address of every printer on my HP-UX server. (There's 256 of them) I'm trying to do it using the PERIPH= value in /etc/lp/interface/<printername>, but I'm having problems scripting it as I'm a bit of a newbie. ... (2 Replies)
Discussion started by: Robin
2 Replies
Login or Register to Ask a Question