Decrypt a GPG file through shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Decrypt a GPG file through shell script
# 1  
Old 07-03-2009
Decrypt a GPG file through shell script

Hi,

I'm trying to decrypt a gpg file thorugh a shell script. But i' could'nt. My script is ,

-sh-3.1$ cat test_gpg.sh
#!/bin/ksh

echo " Hello, iam testing GPG"

gpg prabhu.txt.gpg <<EOF
prompt prabhu
EOF
exit 0


The file i'm trying to decrypt is prabhu.txt.gpg and my passphrase is "prabhu".

Can someone please help me on this ASAP.

---------- Post updated 07-03-09 at 06:37 PM ---------- Previous update was 07-02-09 at 08:51 PM ----------

Hi all,

Just sharing this for informative purpose.

My below script works succesfully.

#!/bin/ksh

### Fetching the password from file or database
pass_phrase=`cat radhas_pwd|awk '{print $1}'`

### Decrypting the encrypted file by passing the passphrase and the output file
gpg --passphrase $pass_phrase --output prabhu.txt --decrypt prabhu.txt.gpg

exit
# 2  
Old 07-05-2009
Quote:
pass_phrase=`cat radhas_pwd|awk '{print $1}'`
UUOC
just this would do
Code:
pass_phrase=`awk '{print $1}' radhas_pwd`

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Encrypt and decrypt the password in a Shell Script

Hello, I have the following UNIX shell script which connects to the teradata database and executes the SQL Queries. For this, I am passing database name, username and password. I don't want to reveal my password to anyone. So, is there any way that I can encrypt my password and read the... (2 Replies)
Discussion started by: ronitreddy
2 Replies

2. Shell Programming and Scripting

Encrypt and decrypt a password in shell script

Hi All, very good morning all. I am trying to connect to informatica repository by using shell script. I have written pmrep connect command in the script file. But i need to provide repository, domain ,username and password to connect. Username and password are hard coded in the script... (8 Replies)
Discussion started by: SekhaReddy
8 Replies

3. Shell Programming and Scripting

Encrypt Password file and decrypt in a shell script

Hi All, I have stored Oracle database passwords in a hidden file - .pass_file. My shell script reads the hidden file, gets the password and then logs in to the Oracle database and runs some SQL script. My requirement is: I need to provide the shell script to be executed by someone else. So,... (1 Reply)
Discussion started by: sunpraveen
1 Replies

4. UNIX for Dummies Questions & Answers

How to decrypt any file in UNIX?

How to decrypt a file in unix? I dont know the type of decryption nor the type of text data it contains. We extracted the file from sfdc & need to process it in unix. When extracted, we get encrypted data in the file. The file content is- ... (0 Replies)
Discussion started by: saga20
0 Replies

5. Shell Programming and Scripting

Need help on File Encryption using gpg

Folks, Is there anyone to help on GPG file encryptions here. I got a public key from third party. I imported the key in server. I want to encrypt the public key. But without being signed , the key cannot be encrypted. When I try to sign the key using lsign command, I am getting the below... (1 Reply)
Discussion started by: dinesh1985
1 Replies

6. Shell Programming and Scripting

Script .ksh to decrypt .gpg(passphrase)

Hi all, i have to make a script in shell unix that decrypt a file .gpg ang through out in the same directory the decypted file. Well, the problem is to put in the shell the passphrase. Here the specifications: File .gpg: bella.zip.gpg File output: bella_decr.zip passphrase: bella_zio ... (4 Replies)
Discussion started by: zangarules
4 Replies

7. Shell Programming and Scripting

Need to decrypt a file in a directory (SHL script)

I need to decrypt a file in a directory, I need to write a shl scrip & cron job How I find the files in the directory: the file is like this: dailypayments_sfs_payment_201011151800.dat -d The decrypt command: gpg -o dailypayments_sfs_payment_201011151800.dat -d 20101115 (the date... (7 Replies)
Discussion started by: rechever
7 Replies

8. Shell Programming and Scripting

decrypt the file

Hello all I am getting a encrypted file (.pgp) and a key which i have to use to decrypt that file. I couldn't understand where to put the key on my unix box so that decryption happens. Please reply. (2 Replies)
Discussion started by: vasuarjula
2 Replies

9. Shell Programming and Scripting

shell script encrypt a file using gpg

Hi, I have a requirement to encrypt a file using gpg with a public key. However when i encrypt a file, i get a question like 'Do you want to go ahead with unverified user?' . when i press 'y' file is encrypted. I am not able to automate this job because of this interactive mode. Could... (3 Replies)
Discussion started by: Deepakbabu
3 Replies

10. Shell Programming and Scripting

Encrypt and Decrypt script

Dear Experts, I am using one script name :volume.sh and its written in bash shell script. I just want to encrypt the script so that any one else cannot see it. please tell me the commands how to encrypt the script as well as to decrypt it. Regards, SHARY (9 Replies)
Discussion started by: shary
9 Replies
Login or Register to Ask a Question