How to use gpg to encrypt data in batch/non-interactive mode?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use gpg to encrypt data in batch/non-interactive mode?
# 1  
Old 07-31-2015
How to use gpg to encrypt data in batch/non-interactive mode?

Hello,
I have to encrypt data using a script in batch mode without being prompted. I can successfully encrypt data but it prompts me to enter (y/N) as shown below. I tried batch flags without no success. I need to automate this without any prompts. Appreciate your inputs.
Thanks,
C.



Code:
$ gpg   --output test.gpg --encrypt --recipient jone_doe@abc.com   test.out
gpg: FC8B84A4: There is no assurance this key belongs to the named user

pub  2048g/FC8B84A4 2006-05-16 jone_doe@abc.com <jone_doe@abc.com>
 Primary key fingerprint: 3D8A 4A1C 2E78 386D B127  C705 47B3 C177 6E2B 6A83
      Subkey fingerprint: 85C9 A419 B16C 4815 3C65  D8C3 A11E 62A3 FC8B 84A4

It is NOT certain that the key belongs to the person named
in the user ID.  If you *really* know what you are doing,
you may answer the next question with yes.

Use this key anyway? (y/N) y
$


Last edited by Corona688; 07-31-2015 at 03:08 PM..
# 2  
Old 07-31-2015
The man page suggests --yes.
# 3  
Old 07-31-2015
I tried with --yes option without success.

Code:
$ gpg --yes --output test.gpg --encrypt --recipient janedoe@abc.com test.out
gpg: FC8B84A4: There is no assurance this key belongs to the named user

pub  2048g/FC8B84A4 2006-05-16 jdoe@abc.com <janedoe@abc.com>
 Primary key fingerprint: 3D8A 4A1C 2E78 386D B127  C705 47B3 C177 6E2B 6A83
      Subkey fingerprint: 85C9 A419 B16C 4815 3C65  D8C3 A11E 62A3 FC8B 84A4

It is NOT certain that the key belongs to the person named
in the user ID.  If you *really* know what you are doing,
you may answer the next question with yes.

Use this key anyway? (y/N) y

Moderator's Comments:
Mod Comment Please use CODE tags; not ICODE tags for full line and for multi-line sample input, output, and code segments.

Last edited by Don Cragun; 07-31-2015 at 07:27 PM.. Reason: Change ICODE tags to CODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Batch processing files through an interactive script

I am newish to the site and to unix. I have a functioning interactive script running on Mac that sorts and processes files located in an unsorted folder on my desktop. As it currently stands, the user types jpg into the command line, the script executes and iterates through the unsorted... (8 Replies)
Discussion started by: Braveheart
8 Replies

2. Shell Programming and Scripting

SFTPing non-interactive mode

Hi All, I need to sftp without any intervention.(LInux,Ksh) I have tried some ideas listed here...but its not working... Please advise on it. (1 Reply)
Discussion started by: jesu
1 Replies

3. UNIX for Advanced & Expert Users

sudo in non interactive mode

Hi , I login to unix using my id and then do a sudo to execute any programs i want. sudo su - <id> password : xxxxxxx Is there a way to make it non interactive so that i can use it in shell script. (1 Reply)
Discussion started by: ashwin3086
1 Replies

4. 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

5. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

6. Shell Programming and Scripting

script to non interactive mode

Gud morning everybody, I need small help form you people,Please advice me. I have a utility(adpatch) which takes 10-15 prompts, i want to automate this by calling this utility in shell script. Now my qiestion i want to run the script in non interactive mode. An example. $adpatch... (1 Reply)
Discussion started by: swetham.apps
1 Replies

7. UNIX for Advanced & Expert Users

SU command in non interactive mode

Can i run the SU command in a non interactive mode. What i want to do is to pass the username and the password as commandline or batch parameters. Please let me if its possible and how to pass them. A sample file will be appreciated. Thanks, (6 Replies)
Discussion started by: rohitag
6 Replies

8. UNIX for Dummies Questions & Answers

Regarding interactive ID of batch job

Hi all, We are running a batch job using Unix script. This batch job is running daily to get data from a Mainframe database and to load our tables. We are using an interactive ID for the batch job. If we removed that interactive ID, the batch job fails. What's my question is.. Is the... (1 Reply)
Discussion started by: pradeep.edara
1 Replies

9. Shell Programming and Scripting

Perl Interactive mode

Hi All, Does perl has an interactive mode like other shell? If there is, can any one show me the equivalent code for the below csh script ? This csh code prompts user for their name and prints the name. #!/bin/csh echo -n "Pls enter the your name: " set name = ($<) echo "You hav... (2 Replies)
Discussion started by: Raynon
2 Replies

10. UNIX for Dummies Questions & Answers

Interactive Mode?

:confused: Can anyone please tell me how to get into Interactive Mode? (2 Replies)
Discussion started by: Nomad
2 Replies
Login or Register to Ask a Question