LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 07-23-2004, 10:22 PM   #1
mchirico
LQ Newbie
 
Registered: Mar 2004
Distribution: Redhat and direct source
Posts: 27

Rep: Reputation: 15
Command Prompt PGP for Email


So, openssl will encrypt a message; but, a password is involved. Here's the "openssl" method of encrypting.

$ openssl des3 -salt -in file.txt -out file.des3 -k secretPassword

and, here's the "openssl" method of decrpyting.

$ openssl des3 -d -salt -in file.des3 -out file.txt -k secretPassword

Whether it's entered at the command prompt with -k or not, the recepient has to be told what the password is, if they are going the read the contents. And, if it's a cron job, then, likely the -k option will used.

Enter GPG. All you need is the recipient's "public" key. No sharing of passwords. What's great is if it's embedded in an email, with the correct "Content-Type:", the end user can automatically open the document in their email.

Here's an example.

$ ./sndmailBash mchirico@comcast.net sporkey@comcast.net " The contents of file.txt" 0xD017E98A < file.txt

This one command will send the contents of "file.txt", from user mchirico@comcast.net to sporkey@comcast.net, using sporkey's public key. When, sporkey gets the email, he'll just be prompted for his pgp password. And the contents will be accessible.

Actually, I use the above method to create reports on system's where I'm not an admin to send to my secure account. There's no private password in this script. But, the real beauty is the content-type change... With lot's of email there's not cut and paste.

Here's the simple script "sndmailBash. The line "gpg -r ${4} --encrypt --armor " encrypts the message. There's nothing new here to seasoned gpg users. What's new is setting the "Content-Type:" to "application/pgp-encrypted" so that the user can automatically open the document.


#!/bin/bash
From=${1}
To=${2}
Subject=${3}


Content=$(gpg -r ${4} --encrypt --armor )


/usr/sbin/sendmail -t <<EOF
From: ${From}
To: ${To}
Subject: ${Subject}
Mime-Version: 1.0
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted";
boundary="B835649000072104Jul07"
Content-Disposition: inline
User-Agent: Mutt/1.4.1i


--B835649000072104Jul07
Content-Type: application/pgp-encrypted
Content-Disposition: attachment

Version: 1

--B835649000072104Jul07
Content-Type: application/octet-stream
Content-Disposition: inline; filename="msg.asc"

${Content}


--B835649000072104Jul07--

EOF

A copy of this program can be found at the following link (See SCRIPT 4)
http://prdownloads.sourceforge.net/s....html?download


I hope this helps. Once you have this simple script, it's easy to "pipe" alerts.

$ iostat | ./sndmailBash mchirico@comcast.net sporkey@comcast.net " The contents of file.txt" 0xD017E98A

Other references for pgp:
http://www.gnupg.org/documentation/faqs.html
http://codesorcery.net/mutt/mutt-gnupg-howto
and

(TIP 86)
http://prdownloads.sourceforge.net/s...e.txt?download


Regards,

Mike Chirico
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Using Aegypten PGP/Mime Email in Mandrake kwalker Linux - Security 1 07-12-2004 02:38 AM
Installing PGP for email clients robertmarkbram Linux - Software 1 01-08-2004 07:55 AM
im only getting command prompt sniperhf Linux - Software 10 06-16-2003 03:19 PM
How to recall an old command at the command prompt? J_Szucs Linux - Newbie 9 03-07-2003 12:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration