Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a public OpenPGP key and need to send an encrypted email using telnet. However, I'm unable to find anything related to this topic.

I have no problem sending an email via telnet, but cannot figure out how to encrypt the mail.

share|improve this question
    
Do you need to do it from command line or you are allowed to write a bash/perl/... script? –  Alois Mahdal Jan 21 '12 at 18:18
    
just one message, so no script necessary. It should be clear, however, that the message was sent from Telnet (so basically no User-Agent in the email header), as this is part of a computer science assignment. –  crank Jan 21 '12 at 18:30
add comment

3 Answers 3

up vote 1 down vote accepted

You will have to encrypt the message text before sending.

Old method: Inline PGP

Earlier, PGP-encrypted messages were included directly in the message body. This is simple and allows using programs that lack built-in PGP support, but has its own issues.

  1. Put the message body (without headers) to body.txt.

  2. gpg --armor --recipient recipient@example.com --encrypt < body.txt > body.gpg

    (or gpg -a -r .... -e)

  3. Open the SMTP session, send the usual envelope and headers, and simply include the contents of body.gpg as message body.

    Example:

    DATA
    354 Send message
    Subject: Encrypted message
    Content-Type: text/plain; charset=utf-8
    
    -----BEGIN PGP MESSAGE-----
    Version: GnuPG v1.4.11 (GNU/Linux)
    
    owE7bZ3E4C/NHB6SkVmsUJ5YnKdeolCUmpiTU6mQmpdcVFlQkpqio5BUWqJQmV+q
    kJ5aolCSkapQkJ+ZV6LHBQA=
    =JTcg
    -----END PGP MESSAGE-----
    .
    250 Queued
    

New method: PGP/MIME

Most mail clients now create a multipart MIME message that looks like this:

Subject: Encrypted message
Content-Type: multipart/encrypted;
    protocol="application/pgp-encrypted";
    boundary="5mzSFVMjvq1PjxJCWywcUUnUEVIaXOtp"

--5mzSFVMjvq1PjxJCWywcUUnUEVIaXOtp
Content-Type: application/pgp-encrypted

Version: 1

--5mzSFVMjvq1PjxJCWywcUUnUEVIaXOtp
Content-Type: application/octet-stream

-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.11 (GNU/Linux)

owE7bZ3E4C/NHB6SkVmsUJ5YnKdeolCUmpiTU6mQmpdcVFlQkpqio5BUWqJQmV+q
kJ5aolCSkapQkJ+ZV6LHBQA=
=JTcg
-----END PGP MESSAGE-----

--5mzSFVMjvq1PjxJCWywcUUnUEVIaXOtp--

Don't bother with this, let a MUA do it.

share|improve this answer
    
Thanks, why didn't I think of it in the first place :D –  crank Jan 21 '12 at 18:43
add comment

Saying telnet suggests one of two things

  • you are using telnet to open a shell session on a Unix server and using it's command line tools such as mail.

  • you are using telnet to open an SMTP session to an SMTP server and typing SMTP commands manually.

I will assume the former.

At the simplest level you can encrypt the body of the message, and, if necessary, convert to a suitable encoding such as base64 before you invoke the mail command.

echo "Send reinforcements" \
| gpg -e -a -r 12345 \
| mail -s "C company" powell@example.com 

Update: OK so you are typing SMTP commands by hand into an SMTP server.

Learn how attachments are serialised. Read the RFCs for MIME attachments. Use Thunderbird to view the source of a short message that has a small attachment (Ctrl+u IIRC). Look for the various ways that binary attachments are encoded so that they can pass through a 7-bit ASCII or 8-bit channel.

You can create the attachment as an external file. Even rot13 would demonstrate the process adequately. Then you just have to work out what MIME etc headings to key in and how to paste in the suitable encoded encrypted attachment during your telnet session.

share|improve this answer
    
Actually, I use telnet to open a SMTP session :) Would it be possible with that? Or is using mail exactly the same as using a telnet session to the SMTP server? It's a task from my computer science course, and if there's something obscure in the header they're probably not going to accept it :( –  crank Jan 21 '12 at 18:11
    
@crank: the end result is the same. I would check the parameters of the assignment. Maybe you are intended to learn more about SMTP and MIME than you might by using other methods?. –  RedGrittyBrick Jan 21 '12 at 18:14
    
They're very clear to use telnet. I just checked and mail adds User-Agent Heirloom mailx, while a direct mail from telnet adds no User-Agent in the email header. Would it be possible to add the encrypted message to the telnet message? And yes, the current subject is protocols :) –  crank Jan 21 '12 at 18:22
    
@crank: Answer updated with a few hints. –  RedGrittyBrick Jan 21 '12 at 18:46
add comment

Many email clients, such as Microsoft Outlook, support encryption. Encryption and decryption is the job of the email client, not the transport mechanism.

To clarify, Telnet is a network protocol (http://en.wikipedia.org/wiki/Telnet ) just like TCP. The protocol has nothing to do with encryption. Most mail clients use TCP/IP to send and receive email via the internet. One commonly used protocol used by mail clients to send an email to a server is Simple Mail Transport Protocol (SMTP). When the sending encrypted email, the encryption must take place prior to handing the message off to the protocol.

Which email client are you using? Does it support encryption? If not, perhaps you should try using a different email client that does, many do.

One of the many free clients that support this is Eudora. Here is a description on how to set this up: http://www.ncsa.illinois.edu/people/hkhurana/mithril/Help-SecureEmail.htm

Mozilla Thunderbird is an open source free client that supports this as well.

share|improve this answer
    
Honestly it's a task from my computer science course. We should send them an email using telnet, and I have been able to do that, but in another task they want us to send them an mail encrypted with PGP using telnet, and this is where I'm really struggling. I have no problem using mail on unix and I personally use Thunderbird –  crank Jan 21 '12 at 17:33
    
-1 for missing the "via telnet" part of the question –  Alois Mahdal Jan 21 '12 at 18:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.