KMail/PGP MIME
Налаштування підписування повідомлень за допомогою GPG у KMail
© Fajar Priyanto, 2004
Створення, збереження та оприлюднення вашого ключа
1. Вам знадобиться програма gpg. Ця програма є частиною типового комплекту програм дистрибутива.
2. Створіть ваш власний ключ (виконайте команду від вашого користувача, не від користувача root):
gpg --gen-key
Виконайте настанови програми: вони очевидні і прості.
3. Перевірте, чи створено ключ:
gpg --list-key
Ви маєте побачити щось подібне до наведеного нижче (ви бачите реєстраційні дані автора статті):
:pub 1024D/85EEC6A5 2004-03-15 Fajar Priyanto (Knowledge is power! http://linux.arinet.org) sub 1024g/BBBB57F3 2004-03-15
4. Зверніть увагу на наведені вище дані. 85EEC6A5 — ідентифікатор ключа. Тепер експортуйте ваш відкритий ключ:
:gpg -ao fajar-pub.key --export 85EEC6A5
У відповідь у поточному каталозі має бути створено файл з назвою fajar-pub.key. У цьому файлі зберігаються дані копії вашого відкритого ключа. Цей файл мають імпортувати отримувачі вашої кореспонденції для перевірки ваших підписаних повідомлень. Ви можете оприлюднити цей ключ на серверах ключів, надіслати його отримувачам за запитом або розмістити його на вашому веб-сайті для звантаження.
Якщо ви зазирнете до файла ви побачите щось таке:
-- --BEGIN PGP PUBLIC KEY BLOCK-- -- Version: GnuPG v1.2.3 (GNU/Linux) mQGiBEBVTw8RBACaYvnDkgqNWyktg3urdE9mrpv63x3Iux2zVkuZk8pIRp5HeR/V [пропущено...] B394acuU4FdGN/EynYUAn1aRvNmgs0/IU2MDzYQpbHIaqpkE =B0cy -- --END PGP PUBLIC KEY BLOCK-- --
Крім того, вам варто створити резервну копію вашого закритого ключа на якомусь безпечному носії даних (однієї дискети для цього замало: її може бути пошкоджено). Скористайтеся такою командою:
$ gpg -ao secret.asc --export-secret-keys 85EEC6A5
This will create a textfile containing your secret or private key, with the filename secret.asc. Do not hand it to someone you do not trust 100%. Hide it in a safe place (or better, more than one).
Finally, it is advisable to generate a revocation certificate and store it in a safe place away from your secret key. In case your secret key gets into the wrong hands, you can revoke it so it can not easily be abused by others. The command to do this is
$ gpg -a -o revoker.asc --gen-revoke 85EEC6A5
This will create a textfile with the name revoker.asc containing the revocation certificate.
Setting up Kmail to sign emails using your gpg key
- Fire up Kmail, and go to
- Choose the identity that you are using
- Then click
- It will automatically go to the path of your gpgkey, that is ~/.gnupg
- Click on the key ID then
- Now, set up Kmail to automatically sign all emails that you write using your key
- Still in the Kmail Configure menu, go to
- Tick mark these:
- Show signed/encrypted message after composing,
- Always show the encryption key for approval,
- Automatically sign messages using OpenPGP?
- Exit the configuration menu by clicking OK.
Testing Kmail by creating a new message
- You will notice that there is a Sign Message icon right after the paperclip (attachment) icon. It's already active.
- Write your message and when you are done, send it.
- Kmail will ask for you to type the secret passphrase that you made during the gpg --gen-key step. Type it in, and then Kmail will show you a confirmation window of the signed message. Click to send it.
- If you test it by sending to yourself, you will notice that Kmail displays the message with a GREEN header, with words like this: Message was signed by Fajar Priyanto (Knowledge is power! http://linux.arinet.org) (Key ID: 0x85EEC6A5). The signature is valid and the key is ultimately trusted.
- People that have your public key will have that display also, but those who don't have the key, will have the message displayed in yellow with words like this: Message was signed with unknown key 0xBFE7357F. The validity of the signature cannot be verified.
CONGRATULATIONS!
You now can communicate in a more secure way if you want to. I know this how-to is very short and might not be very clear. Well, please give me suggestions and I will improve it when the time comes. Also I intend to write the second part of this topic which covers how to ENCRYPT messages, import other public keys, and install Crypto Plug-ins. Special thanks to Tim Sawchuck and Philip Cronje and all my friends in the Mandrake List.
Issues
- Messages signed by a key already known display correctly in KMail, but new keys were not being imported, and you can't sign messages. The culprit is a missing package. Installing pinentry-qt (you may need pinentry-qt4) appears to solve both problems.
- KMail no longer does in-line signatures. OpenGPG has to be used instead. KGpg is a useful applet that helps in the management of signatures, both your own and those collected.
- If OpenGPG is functioning correctly you will have to give the pass-phrase every time you send a document that is to be signed. This soon becomes a pain, and the way out of that is to configure gpg-agent, which comes with kdebase-common package. Unfortunately, the install does not pick up the need for pinentry-qt(4) or pinentry-gtk (KDE or GNOME), so that has to be installed separately. The config file for gpg-agent is written to by KMail's settings.
- If you do not have it already, in ~/.kde create a directory called env. In there, create a file called gpgagent.sh containing
#!/bin/bash killall gpg-agent eval `gpg-agent --daemon`
Save it and make it executable.
In the same way you would clean up gpg-agent on shutdown, so if you do not have it already, create another directory called shutdown into ~/.kde and create in it another script file called stop_gpgagent.sh containing
#!/bin/bash killall gpg-agent
Save it and make it executable.
Troubleshooting Tips
grep gpg-agent
will list any running instances of gpg-agent.
killall gpg-agent
stops all instances
eval "$(gpg-agent --daemon)"
will restart the agent
{Input|1=gpg-agent status}}should tell you if the agent is running.