1 # -*- coding: utf-8-unix -*-
2 #+TITLE: edit-keyオプションの使い方
4 #+EMAIL: hideki@hidekisaito.com
5 #+DESCRIPTION: Emacs Builds prepared by Hideki Saito
6 #+KEYWORDS: Emacs, software, OSS, compile, build, binaries
8 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css" />
9 #+HTML_HEAD: <script type="text/javascript">
11 #+HTML_HEAD: var _gaq = _gaq || [];
12 #+HTML_HEAD: _gaq.push(['_setAccount', 'UA-114515-7']);
13 #+HTML_HEAD: _gaq.push(['_trackPageview']);
15 #+HTML_HEAD: (function() {
16 #+HTML_HEAD: var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
17 #+HTML_HEAD: ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
18 #+HTML_HEAD: var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
20 #+HTML_HEAD: </script>
23 #+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
24 #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
26 #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:h
27 #+EXPORT_SELECT_TAGS: export
28 #+EXPORT_EXCLUDE_TAGS: noexport
29 #+HTML_LINK_UP: index.html
30 #+HTML_LINK_HOME: index.html
34 GnuPGでは–edit-keyのオプションを使用して鍵(秘密鍵、または公開鍵)に対して変更を行ったり、情報を参照したりすることができます。 今回の特集ではそのオプション、特に鍵に変更を加えるものを見ていく事にします。 尚、このモードではコマンドラインから行う事ができる鍵への署名、破棄などをインタラクティブに行う事もできます。 (尚、これらは高度なオプションが含まれますので慎重に行う事をお勧めします。)
38 利用するのには以下のようにコマンドラインに入力します。
41 gpg --edit-key 0x565A5E2A
44 この時、秘密鍵を使用できる場合は「Secret key is available.」と表示されます。(日本語化がなされている場合は「秘密鍵が使用できます。」となりますが今回の説明では英語で表示された場合のものを表示します。
48 gpg --edit-key 0x565A5E2A
52 gpg (GnuPG) 1.2.3; Copyright (C) 2003 Free Software Foundation, Inc.
53 This program comes with ABSOLUTELY NO WARRANTY.
54 This is free software, and you are welcome to redistribute it
55 under certain conditions. See the file COPYING for details.
56 Secret key is available.
58 pub 1024D/565A5E2A created: 2003-12-07 expires: never trust: u/u
59 sub 2048g/E8D70F9E created: 2003-12-07 expires: never
61 (1). FooBar (Not a production key) [email protected]>
66 ここでhelpと入力すると以下のような表示が行われます。
74 list list key and user IDs
76 key select secondary key N
79 lsign sign the key locally
80 nrsign sign the key non-revocably
81 nrlsign sign the key locally and non-revocably
83 addphoto add a photo ID
85 addkey add a secondary key
86 delkey delete a secondary key
87 addrevoker add a revocation key
88 delsig delete signatures
89 expire change the expire date
90 primary flag user ID as primary
91 toggle toggle between secret and public key listing
92 pref list preferences (expert)
93 showpref list preferences (verbose)
94 setpref set preference list
95 updpref updated preferences
96 passwd change the passphrase
97 trust change the ownertrust
98 revsig revoke signatures
99 revuid revoke a user ID
100 revkey revoke a secondary key
101 disable disable a key
103 showphoto show photo ID
106 いろいろとオプションがありますが、これは日本語では以下のようになります。
121 nrlsign 失効できないよう鍵へ内部的に署名
131 toggle 秘密鍵と公開鍵の一覧の切替え
147 showprefコマンドを使用する事により鍵の特性が表示されます。
152 pub 1024D/565A5E2A created: 2003-12-07 expires: never trust: u/u
153 (1). FooBar (Not a production key) [email protected]>
154 Cipher: AES256, AES192, AES, CAST5, 3DES
155 Digest: SHA1, RIPEMD160
156 Compression: ZLIB, ZIP, Uncompressed
160 上から暗号、署名、圧縮、機能に使用するアルゴリズムを表示します。 これは最初に表示されているものから優先して使用する事ができます。 尚、この順番を入れ替えたり、特定のアルゴリズムを使用しないようにすることもできます。 これをするのにはsetprefオプションを使用します。
164 prefコマンドを使用すると以下のような表示を得る事ができます。
169 pub 1024D/565A5E2A created: 2003-12-07 expires: never trust: u/u
170 (1). FooBar (Not a production key) [email protected]>
171 S9 S8 S7 S3 S2 H2 H3 Z2 Z1 [mdc]
174 setprefコマンドと表示されているスタイルの指定をすることによりそれを指定する事ができます。 つまり、例えば3DESを使用したくない場合は、以下のように指定します。(厳密には3DESを無効にしても他に使用できるものが見つからない場合はこの設定を無視して3DESによる暗号化が行われます。これは3DESがOpenPGPで必須のアルゴリズムとされているためです。)
177 setpref S9 S8 S7 S3 H2 H3 Z2 Z1
180 この時点ではこの変更は行われていません。 次に以下のコマンドを入力します。
191 Current preference list: S9 S8 S7 S3 H2 H3 Z2 Z1 [mdc]
192 Really update the preferences?
195 ここでyを入力するとsetprefで行った変更を行うためにパスフレーズの入力を要求します。 そして、saveと入力してedit-keyモードから抜けると変更が有効になります。
198 expireコマンドではその有効期限を変更する事ができます。 expireコマンドの実行で以下のような設定をすることができます。
203 Changing expiration time for the primary key.
204 Please specify how long the key should be valid.
205 0 = key does not expire
206 = key expires in n days
207 w = key expires in n weeks
208 m = key expires in n months
209 y = key expires in n years
211 Key is valid for? (0)
215 指定は0で無期限もしくは数字で日数、またはその後に、w、m、yの単位を入力することにより週、月、年の単位で指定する事ができます。 例えば1yと入力する事により一年間有効にする事ができます。
219 指定した鍵に複数の副鍵がある場合は少し特殊な操作が必要にある必要があります。 副鍵がある場合、鍵を表示すると以下のような表示になります。
223 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
224 sub 1024g/88480126 created: 2003-12-08 expires: never
225 sub 1024R/E5FFF9CD created: 2003-12-08 expires: never
226 (1). FooBar (Not for a production use)
229 普通に鍵の変更をしようとすると主鍵の変更となります。 どの鍵に対して変更をしようとしているかはコマンドを使用する時の表示で判別することができます。
236 Changing expiration time for the primary key.
237 Please specify how long the key should be valid.
239 0 = key does not expire
240 = key expires in n days
241 w = key expires in n weeks
242 m = key expires in n months
243 y = key expires in n years
245 Key is valid for? (0)
248 上記の表示のように、”~ for the primary key.”という表示で主鍵に変更を加えようとしていることがわかります。
249 副鍵に変更を加えるにはkeyコマンドを使用します。
252 gpg --edit-key foobar
256 gpg (GnuPG) 1.2.3; Copyright (C) 2003 Free Software Foundation, Inc.
258 This program comes with ABSOLUTELY NO WARRANTY.
259 This is free software, and you are welcome to redistribute it
260 under certain conditions. See the file COPYING for details.
261 Secret key is available.
263 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
264 sub 1024g/88480126 created: 2003-12-08 expires: never
265 sub 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
267 (1). FooBar (Not for a production use)
271 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
272 sub 1024g/88480126 created: 2003-12-08 expires: never
273 sub* 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
275 (1). FooBar (Not for a production use)
278 ここで打ち込んだkey 2のコマンドによってE5FFF9CDの鍵に*マークがついたのがわかると思います。 これにより今行う変更はこの副鍵に対して行われます。これは複数の鍵を選択する事も可能でこの場合は以下のようになります。
285 gpg (GnuPG) 1.2.3; Copyright (C) 2003 Free Software Foundation, Inc.
286 This program comes with ABSOLUTELY NO WARRANTY.
287 This is free software, and you are welcome to redistribute it
288 under certain conditions. See the file COPYING for details.
289 Secret key is available.
291 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
292 sub 1024g/88480126 created: 2003-12-08 expires: never
293 sub 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
294 sub 1024R/9A8AA276 created: 2003-12-10 expires: never
296 (1). FooBar (Not for a production use)
300 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
301 sub 1024g/88480126 created: 2003-12-08 expires: never
302 sub* 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
303 sub 1024R/9A8AA276 created: 2003-12-10 expires: never
305 (1). FooBar (Not for a production use)
309 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
310 sub 1024g/88480126 created: 2003-12-08 expires: never
311 sub* 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
312 sub* 1024R/9A8AA276 created: 2003-12-10 expires: never
314 (1). FooBar (Not for a production use)
317 expireなどの一定のコマンドは一つの鍵のみが選択されている必要があります。
320 <script type="text/javascript"><!--
321 google_ad_client = "ca-pub-6327257212970697";
322 /* GNU Privacy Guard講座Banner */
323 google_ad_slot = "2155169100";
324 google_ad_width = 970;
325 google_ad_height = 90;
328 <script type="text/javascript"
329 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">