·¢²©ÎÄ
¾²Ë®ÉîÁ÷

http://blog.chinaunix.net/space.php?uid=20368611

Paolo.Wang ÍõÕß   
¸öÈË×ÊÁÏ
  • ²©¿Í·ÃÎÊ£º114878
  • ²©ÎÄÊýÁ¿£º34
  • ²©¿Í»ý·Ö£º2125
  • ²©¿ÍµÈ¼¶£º´óξ
  • ×¢²áʱ¼ä£º2006-05-29 00:05:45
¶©ÔÄÎҵIJ©¿Í
  • ¶©ÔÄ
  • ¶©Ôĵ½Ïʹû
  • ¶©Ôĵ½×¥Ïº
  • ¶©Ôĵ½Google
×ÖÌå´óС£º´ó ÖРС²©ÎÄ
·ÖÀࣺ LinuxÏà¹Ø


linuxϵͳ»·¾³Ï£¬¶ÔÎļþ½øÐмÓÃÜ£¨gpg,openssl£©
Linux¹ØÓÚÎļþ¼ÓÃܵÄÁ½ÖÖ·½·¨ºÍÏê½â£º
Ò»¡¢ÓÃGnuPG¼ÓÃÜÎļþ¡£
GnuPGÈí¼þ°ü£¨Gnu Privacy Guard,GnuÒþ˽±£ïÚ£©,Èí¼þ°üµÄÃû³ÆÊÇgpg¡£
gpgÔÚ¼ÓÃÜÎļþʱʹÓõÄÊǹ«¹²ÃÜÔ¿¼ÓÃÜ·½·¨¡£
1.µÚÒ»²½ÊÇÒª´´½¨Ò»¸ö½«À´ÓÃÀ´·¢ËͼÓÃÜÊý¾ÝºÍ½øÐнâÃÜÊý¾ÝµÄÃÜÔ¿¡£ÎÒÃÇÖ´ÐÐÒ»ÏÂgpgÃüÁ¾Í»áÔÚÄãµÄÖ÷Ŀ¼Ï´´½¨Ò»¸ö.gnupg×ÓĿ¼¡£
£¨Èç¹ûËü²»´æÔڵϰ£¬ÓÐʱÒѾ­´æÔÚÁË£©¡£ÔÚ¸Ã×ÓĿ¼ÀïÃæÓÐÒ»¸ögpg.confµÄÅäÖÃÎļþ£¬ËüÀïÃæÊÇgpg¹¤¾ßµÄ¸÷ÖÖÅäÖÃÑ¡Ïî¼°ÆäĬÈÏÉèÖÃÖµ¡£
½ÓÏÂÀ´£¬ÎÒÃÇÀ´½øÐеÚÒ»ÏÉú³ÉÃÜÔ¿£º
[root@fxvsystem root]# gpg --gen-key                         >>Õâ¸öÃüÁîÉú³ÉÃÜÔ¿
gpg (GnuPG) 1.2.4; Copyright (C) 2003 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Please select what kind of key you want:                    >>Ñ¡ÔñÃÜÔ¿ÀàÐÍ
   (1) DSA and ElGamal (default)
   (2) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
About to generate a new ELG-E keypair.                      >>Ñ¡ÔñÃÜÔ¿³¤¶È
              minimum keysize is  768 bits
              default keysize is 1024 bits
    highest suggested keysize is 2048 bits
What keysize do you want? (1024) 768
Requested keysize is 768 bits      
Please specify how long the key should be valid.            >>Ñ¡ÔñÃÜÔ¿ÓÐЧÆÚ£¬0´ú±íûÓÐÆÚÏÞ
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct (y/n)? y                                     >>×îºóÈ·ÈÏÊÇ·ñÕýÈ·                       
You need a User-ID to identify your key; the software constructs the user id
from Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: test201                                           >>ÊäÈë»ù±¾ÐÅÏ¢£¬ÕæÊµÃû×Ö
Email address: test201@test201.com                           >>ÊäÈëÓʼþµØÖ·
Comment: this is 201 key                                     >>ÆäËûÏà¹Ø×¢ÊÍÐÅÏ¢
You selected this USER-ID:
    "test201 (this is 201 key) <test201@test201.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O                >>È·ÈÏOK
You need a Passphrase to protect your secret key.   
Enter passphrase:                                            >>ÊäÈëÃÜÔ¿¿ÚÁî
Repeat passphrase:
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
+++++.+++++++++++++++++++++++++++++++++++++++++++++.+++++..+++++++++++++++++++++++++++++++++++++++++++++.+++++..++++++++++.+++++++++++++++>.++++++++++...........................................................+++++
                                                                         >>Éú³ÉÃÜÔ¿¹ý³Ì»á³öÏÖÁ¬ÐøµÄÕâÖÖ·ûºÅ¡£
Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 215 more bytes)
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.                         >>Õâ¶Î»°±íÃ÷ÌáʾÎÒÃÇÔÚϵͳÉÏ´´½¨Ò»Ð©Ëæ»úµÄ»î¶¯£¬Èç¹ûûÓÐ×ã¹»µÄ»î¶¯£¬Ëû»áÍ£ÏÂÀ´ÌáʾÎÒÃǼÌÐøÕâÑù×ö¡££¨±ÈÈç²é¿´Ò»ÏÂcpu,ËæÒâÇôòһϼüÅ̶¼¿ÉÒÔ£©
++++++++++.+++++++++++++++.++++++++++++++++++++.++++++++++.+++++++++++++++++++++++++.+++++.+++++.+++++++++++++++.+++++.++++++++++++++++++++....>+++++..+++++^^^^^
gpg: /root/.gnupg/trustdb.gpg: trustdb created
public and secret key created and signed.
key marked as ultimately trusted.
pub  1024D/BA56DDDA 2007-01-16 test201 (this is 201 key) <test201@test201.com>                   ÕâÐÐÀïÃæµÄBA56DDDAÊÇÉú³ÉµÄ¹«¹²ÃÜÔ¿µÄ±êʶ£¬ÎÒÃÇÔÚºóÃæ»¹ÒªÊ¹Ó㬼ÇסËü°É¡£
     Key fingerprint = 98E8 0A56 9E16 F61B 379D  2F53 D5DF 4117 BA56 DDDA
sub   768g/8F754496 2007-01-16
                                                                         >>³É¹¦
[root@fxvsystem root]#
ÏÖÔÚÎÒÃÇÒѾ­Éú³ÉÁËÒ»¶ÔÃÜÔ¿¡£²é¿´.gnupgĿ¼£º
[root@fxvsystem root]# cd .gnupg/
[root@fxvsystem .gnupg]# ll
total 24
-rw-------  1 root root 8075 Jan 16 11:10 gpg.conf
-rw-------  1 root root  856 Jan 16 11:30 pubring.gpg                ´æ·Å±ðÈ˹«¹²ÃÜÔ¿µÄ¡°Ô¿³×»·¡±Îļþ¡£
-rw-------  1 root root    0 Jan 16 11:10 pubring.gpg~
-rw-------  1 root root  600 Jan 16 11:30 random_seed
-rw-------  1 root root  991 Jan 16 11:30 secring.gpg
-rw-------  1 root root 1240 Jan 16 11:30 trustdb.gpg
[root@fxvsystem .gnupg]#
ÓÖÐÂÉú³ÉÁ˼¸¸öÏà¹ØµÄÎļþ¡£
2.ΪÁ˰ѸղÅÉú³ÉµÄ¹«¹²ÃÜÔ¿·¢Ë͸ø¶Ô·½£¬ÎÒÃÇÐèÒªÏÈÓÃÃüÁî°ÑËüÌáÈ¡³öÀ´£º
[root@fxvsystem gpg]# gpg --armor --export BA56DDDA > 201.key        °Ñ¹«¹²ÃÜÔ¿ÌáÈ¡µ½Îļþ201.keyÖС£
ÆäÖУº
--armorÊÇÈÃgpgÉú³ÉASCII¸ñʽµÄÊä³ö£¬ÕâÑùÊʺϵç×ÓÓʼþÀ´·¢ËÍ¡£Èç¹û¿ÉÒÔʹÓÃsshµÈÖ§³Ö¶þ½øÖÆÎļþ´«ÊäµÄ¹¤¾ß¡£¿ÉÒÔ²»Ê¹ÓÃÕâ¸öÑ¡Ïî¡£
--export  ¾Í²»Óöà˵ÁË£¬¾ÍÊǵ¼³öµÄÒâ˼¡£

3.ÔÚÊÕµ½±ðÈË´«¹ýÀ´µÄ¹«¹²ÃÜÔ¿ºó£¬ÐèÒª°ÑÕâ¸ö¹«¹²ÃÜÔ¿·Åµ½¡°Ô¿³×»·¡±ÎļþÀ
±ÈÈ磬ÎÒÃÇÔÚÁíһ̨¼ÆËã»úÉÏÊÕµ½Á˸ղÅ201.keyÕâ¸ö¹«¹²ÃÜÔ¿£¬È»ºóÎÒÃÇÖ´ÐУº
[root@localhost gpg]# gpg --import 201.key
gpg: key BA56DDDA: public key "test201 (this is 201 key) <test201@test201.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
ͨ¹ýÕâÌõÃüÁ¿ÉÒ԰ѸղÅÔÚ201»úÆ÷ÉÏÉú³ÉµÄ¹«¹²ÃÜÔ¿µ¼Èëµ½161»úÆ÷µÄ¡°Ô¿³×»·¡±Îļþ£¨~/.gnupg/pubring.gpg£©ÖС£
¿ÉÒÔͨ¹ýgpg -kvÃüÁî²é¿´161»úÆ÷Éϵ±Ç°´æ·Å¶àÉÙ¸ö±ðÈ˵Ĺ«¹²ÃÜÔ¿£º
[root@localhost gpg]# gpg -kv
/root/.gnupg/pubring.gpg
------------------------
pub   1024D/1C05EC6B 2007-01-15
uid                  Paolo (this test destination 213) <wangqi@livedoor.cn>
sub   1024g/A16A8685 2007-01-15
pub   1024D/BC3AA97D 2007-01-15
uid                  Wangqi (test to 161) <wangqi@livedoor.cn>
sub   1024g/33A9764D 2007-01-15
pub   1024D/BA56DDDA 2007-01-16
uid                  test201 (this is 201 key) <test201@test201.com>
sub    768g/8F754496 2007-01-16
[root@localhost gpg]#
4.½ÓÏÂÀ´£¬ÎÒÃÇÔÚ161»úÆ÷ÉÏÓÃ201µÄ¹«¹²ÃÜÔ¿¼ÓÃÜÒ»¸öÎļþ
[root@localhost ~]# gpg -ea -r BA56DDDA install.log               >>ͨ¹ýÕâ¸öÃüÁî¶Ôinstall.logÎļþ½øÐмÓÃÜ¡£
gpg: 8F754496: There is no assurance this key belongs to the named user
pub   768g/8F754496 2007-01-16 test201 (this is 201 key) <test201@test201.com>
 Primary key fingerprint: 98E8 0A56 9E16 F61B 379D  2F53 D5DF 4117 BA56 DDDA
      Subkey fingerprint: DC76 48E6 70C0 CD36 F671  D2D3 AEC5 02A2 8F75 4496
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
[root@localhost ~]# ls
-e   ´ú±í¼ÓÃÜ
-a   ´ú±íASCII¸ñʽ£¬Èç¹û²»ÊÇͨ¹ýµç×ÓÓʼþ´«Ê䣬¿É²»¼Ó´Ë²ÎÊý
-r   ºóÃæÊÇÃÜÔ¿µÄ±êʶ¡£¿ÉÒÔʹÓöà¸ö-r²ÎÊý£¬¼Ó¶à¸ö±êʶ£¬ÕâÑù¾Í¿ÉÒÔ°ÑËü·¢¸ø¶à¸öÐèÒª¸ÃÎļþµÄÈË¡£
Õâ¸öÃüÁîÖ´ÐÐÖ®ºó£¬ÔÚµ±Ç°Ä¿Â¼Ï²鿴£¬Éú³ÉÁËÒ»¸öͬÃûµÄinstall.log.ascµÄÎļþ£¬Õâ¸öÎļþ¾ÍÊǼÓÃܺóµÄÎļþ¡£

5.×îºóÎÒÃǰÑinstall.log.ascÎļþ´«»Øµ½201»úÆ÷ÉÏ£¬½øÐнâÃܲ鿴£º
[root@fxvsystem gpg]# ls
201.key  install.log.asc
[root@fxvsystem gpg]# gpg -o install.log -d install.log.asc                   >>Õâ¸öÃüÁî½øÐнâÃÜ,-oΪÊä³öµ½Ò»¸öÎļþÖУ¬-d±íʾ½âÃÜ¡£
You need a passphrase to unlock the secret key for
user: "test201 (this is 201 key) <test201@test201.com>"
768-bit ELG-E key, ID 8F754496, created 2007-01-16 (main key ID BA56DDDA)
gpg: encrypted with 768-bit ELG-E key, ID 8F754496, created 2007-01-16
      "test201 (this is 201 key) <test201@test201.com>"
[root@fxvsystem gpg]# ls
201.key  install.log  install.log.asc
[root@fxvsystem gpg]#
ÎÒÃÇ¿ÉÒÔ¿´µ½ÔÚµ±Ç°Ä¿Â¼ÏÂÉú³ÉÁËÒ»¸öinstall.logÎļþ£¬Õâ¸öÎļþ¾ÍÊǽâÃܺóµÄÎļþ£¬¿ÉÒÔÖ±½Ó²é¿´¡£
 
 
¶þ¡¢ÓÃopenssl¼ÓÃÜÎļþ
opensslÒ²¿ÉÒÔ½øÐÐÎļþµÄ¼ÓÃÜ¡£·½·¨±ÈÉÏÃæµÄgpg¼òµ¥ºÜ¶à£¬Ã»Óд´½¨ÃÜÔ¿µÄ¹ý³Ì£¬Ò²Ã»ÓÐÏà¹ØµÄÅäÖÃÎļþ£¬Ö»ÒªÖ´ÐÐÒ»ÌõÃüÁî¾Í¿ÉÒÔ¶ÔÎļþ½øÐмÓÃÜ¡£
°Ñ¼ÓÃܵÄÎļþ´«¸øÐèÒªµÄÈ˺ó£¬Ö»ÒªËûÖªµÀ¼ÓÃÜ·½Ê½ºÍ¼ÓÃÜ¿ÚÁ¾Í¿ÉÒÔ½âÃܲ鿴Îļþ¡£
opensslÖ§³ÖµÄ¼ÓÃÜËã·¨ºÜ¶à£¬°üÀ¨£ºbf,cast,des,des3,idea,rc2,rc5µÈ¼°ÒÔÉϸ÷ÖֵıäÌ壬¾ßÌå¿É²ÎÔÄÏà¹ØÎĵµ¡£
¾ßÌåµÄ·½·¨ÈçÏ£º
1.¼ÓÃÜÒ»¸öÎļþ£º
[root@fxvsystem root]# openssl enc -des -e -a -in install.log -out install.log.des
enter des-cbc encryption password:
Verifying - enter des-cbc encryption password:
ÊäÈëÃÜÂëÖ®ºó£¬¾Í»áÉú³Éinstall.log.desÎļþ£¬Õâ¸öÎļþÃûÊÇ×Ô¼ºÖ¸¶¨µÄ£¬¿ÉÒÔËæÒâд¡£
ÆäÖУº
enc±íÃ÷Äã´òËãʹÓÃij¸öËã·¨
-desÊǾßÌåʹÓõÄij¸öËã·¨
-e ±íÃ÷Òª¼ÓÃÜ
-a ͬÑùÊÇʹÓÃASCII½øÐбàÂë
-in  Òª¼ÓÃܵÄÎļþÃû×Ö
-out ¼ÓÃܺóµÄÎļþÃû×Ö

°ÑÉú³ÉµÄÎļþ´«µ½Áíһ̨»úÆ÷ºó£¬Ö´ÐÐÈçÏÂÃüÁî½øÐнâÃÜ
[root@fxvsystem gpg]# openssl enc -des -d -a -in install.log.des -out install.log
enter des-cbc decryption password:
ÊäÈë¿ÚÁîºó£¬¾Í¿ÉÒԵõ½½âÃܺóµÄÎļþÁË¡£
ÆäÖÐ
-d±íÃ÷Òª½øÐнâÃÜ
 

[·¢ÆÀÂÛ] ÆÀÂÛ ÖØÒªÌáʾ£º¾¯ÌèÐé¼ÙÖн±ÐÅÏ¢!
  • Alan_Shu 2008-06-19 20:25
    1¡¢ÏÂÔØopensslÔ´´úÂë°ü 2¡¢½âѹËõ½øÈëĿ¼£¬ÐÞ¸Äapps/openssl.c£¬¼ÓÈë #define _LARGEFILE_SOURCE //for LFS support #define _FILE_OFFSET_BITS 64 //for LFS support 3¡¢±àÒë¶þ½øÖưü£¬ÎÊÌâFIX ×¢£º¶à´ÎÓöµ½²»Ö§³Ö2GÎļþÎÊÌ⣬´Ë·½·¨ÂÅÊÔ²»Ë¬¡£Å·ÁËÅ·ÁË£¡
  • Alan_Shu 2008-06-19 20:22
    Î÷·½²»Ê¤ ʱ¼ä£º2008-05-30 15:29:59 IPµØÖ·£º222.66.40.¡ï openssl¼ÓÃÜÎļþÓÐ2GB´óСÏÞÖÆ£¬²»ÖªÐֵܿÉÓнâ¾ö°ì·¨£¿ ÎÒ¼´¾öµôÁË
  • chinaunixÍøÓÑ 2008-05-30 15:29
    openssl¼ÓÃÜÎļþÓÐ2GB´óСÏÞÖÆ£¬²»ÖªÐֵܿÉÓнâ¾ö°ì·¨£¿
  • chinaunixÍøÓÑ 2008-01-02 15:23
    ²»´í ллÁË ÊܽÌÁË
Ç×£¬Äú»¹Ã»ÓеǼ,Çë[µÇ¼]»ò[×¢²á]ºóÔÙ½øÐÐÆÀÂÛ