2 title = "edit-keyオプションの使い方"
10 GnuPGでは–edit-keyのオプションを使用して鍵(秘密鍵、または公開鍵)に対して変更を行ったり、情報を参照したりすることができます。 今回の特集ではそのオプション、特に鍵に変更を加えるものを見ていく事にします。 尚、このモードではコマンドラインから行う事ができる鍵への署名、破棄などをインタラクティブに行う事もできます。 (尚、これらは高度なオプションが含まれますので慎重に行う事をお勧めします。)
15 利用するのには以下のようにコマンドラインに入力します。
17 gpg --edit-key 0x565A5E2A
19 この時、秘密鍵を使用できる場合は「Secret key is available.」と表示されます。(日本語化がなされている場合は「秘密鍵が使用できます。」となりますが今回の説明では英語で表示された場合のものを表示します。
21 gpg --edit-key 0x565A5E2A
23 gpg (GnuPG) 1.2.3; Copyright (C) 2003 Free Software Foundation, Inc.
24 This program comes with ABSOLUTELY NO WARRANTY.
25 This is free software, and you are welcome to redistribute it
26 under certain conditions. See the file COPYING for details.
27 Secret key is available.
29 pub 1024D/565A5E2A created: 2003-12-07 expires: never trust: u/u
30 sub 2048g/E8D70F9E created: 2003-12-07 expires: never
32 (1). FooBar (Not a production key) [email protected]>
36 ここでhelpと入力すると以下のような表示が行われます。
43 list list key and user IDs
45 key select secondary key N
48 lsign sign the key locally
49 nrsign sign the key non-revocably
50 nrlsign sign the key locally and non-revocably
52 addphoto add a photo ID
54 addkey add a secondary key
55 delkey delete a secondary key
56 addrevoker add a revocation key
57 delsig delete signatures
58 expire change the expire date
59 primary flag user ID as primary
60 toggle toggle between secret and public key listing
61 pref list preferences (expert)
62 showpref list preferences (verbose)
63 setpref set preference list
64 updpref updated preferences
65 passwd change the passphrase
66 trust change the ownertrust
67 revsig revoke signatures
68 revuid revoke a user ID
69 revkey revoke a secondary key
72 showphoto show photo ID
74 いろいろとオプションがありますが、これは日本語では以下のようになります。
88 nrlsign 失効できないよう鍵へ内部的に署名
115 showprefコマンドを使用する事により鍵の特性が表示されます。
119 pub 1024D/565A5E2A created: 2003-12-07 expires: never trust: u/u
120 (1). FooBar (Not a production key) [email protected]>
121 Cipher: AES256, AES192, AES, CAST5, 3DES
122 Digest: SHA1, RIPEMD160
123 Compression: ZLIB, ZIP, Uncompressed
126 上から暗号、署名、圧縮、機能に使用するアルゴリズムを表示します。 これは最初に表示されているものから優先して使用する事ができます。 尚、この順番を入れ替えたり、特定のアルゴリズムを使用しないようにすることもできます。 これをするのにはsetprefオプションを使用します。
129 prefコマンドを使用すると以下のような表示を得る事ができます。
133 pub 1024D/565A5E2A created: 2003-12-07 expires: never trust: u/u
134 (1). FooBar (Not a production key) [email protected]>
135 S9 S8 S7 S3 S2 H2 H3 Z2 Z1 [mdc]
137 setprefコマンドと表示されているスタイルの指定をすることによりそれを指定する事ができます。 つまり、例えば3DESを使用したくない場合は、以下のように指定します。(厳密には3DESを無効にしても他に使用できるものが見つからない場合はこの設定を無視して3DESによる暗号化が行われます。これは3DESがOpenPGPで必須のアルゴリズムとされているためです。)
139 setpref S9 S8 S7 S3 H2 H3 Z2 Z1
141 この時点ではこの変更は行われていません。 次に以下のコマンドを入力します。
149 Current preference list: S9 S8 S7 S3 H2 H3 Z2 Z1 [mdc]
150 Really update the preferences?
152 ここでyを入力するとsetprefで行った変更を行うためにパスフレーズの入力を要求します。 そして、saveと入力してedit-keyモードから抜けると変更が有効になります。
157 expireコマンドではその有効期限を変更する事ができます。 expireコマンドの実行で以下のような設定をすることができます。
161 Changing expiration time for the primary key.
162 Please specify how long the key should be valid.
163 0 = key does not expire
164 = key expires in n days
165 w = key expires in n weeks
166 m = key expires in n months
167 y = key expires in n years
169 Key is valid for? (0)
171 指定は0で無期限もしくは数字で日数、またはその後に、w、m、yの単位を入力することにより週、月、年の単位で指定する事ができます。 例えば1yと入力する事により一年間有効にする事ができます。
176 指定した鍵に複数の副鍵がある場合は少し特殊な操作が必要にある必要があります。 副鍵がある場合、鍵を表示すると以下のような表示になります。
179 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
180 sub 1024g/88480126 created: 2003-12-08 expires: never
181 sub 1024R/E5FFF9CD created: 2003-12-08 expires: never
182 (1). FooBar (Not for a production use)
184 普通に鍵の変更をしようとすると主鍵の変更となります。 どの鍵に対して変更をしようとしているかはコマンドを使用する時の表示で判別することができます。
191 Changing expiration time for the primary key.
192 Please specify how long the key should be valid.
194 0 = key does not expire
195 = key expires in n days
196 w = key expires in n weeks
197 m = key expires in n months
198 y = key expires in n years
200 Key is valid for? (0)
202 上記の表示のように、”~ for the primary key.”という表示で主鍵に変更を加えようとしていることがわかります。
203 副鍵に変更を加えるにはkeyコマンドを使用します。
205 gpg --edit-key foobar
207 gpg (GnuPG) 1.2.3; Copyright (C) 2003 Free Software Foundation, Inc.
209 This program comes with ABSOLUTELY NO WARRANTY.
210 This is free software, and you are welcome to redistribute it
211 under certain conditions. See the file COPYING for details.
212 Secret key is available.
214 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
215 sub 1024g/88480126 created: 2003-12-08 expires: never
216 sub 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
218 (1). FooBar (Not for a production use)
222 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
223 sub 1024g/88480126 created: 2003-12-08 expires: never
224 sub* 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
226 (1). FooBar (Not for a production use)
228 ここで打ち込んだkey 2のコマンドによってE5FFF9CDの鍵に\*マークがついたのがわかると思います。 これにより今行う変更はこの副鍵に対して行われます。これは複数の鍵を選択する事も可能でこの場合は以下のようになります。
232 gpg (GnuPG) 1.2.3; Copyright (C) 2003 Free Software Foundation, Inc.
233 This program comes with ABSOLUTELY NO WARRANTY.
234 This is free software, and you are welcome to redistribute it
235 under certain conditions. See the file COPYING for details.
236 Secret key is available.
238 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
239 sub 1024g/88480126 created: 2003-12-08 expires: never
240 sub 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
241 sub 1024R/9A8AA276 created: 2003-12-10 expires: never
243 (1). FooBar (Not for a production use)
247 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
248 sub 1024g/88480126 created: 2003-12-08 expires: never
249 sub* 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
250 sub 1024R/9A8AA276 created: 2003-12-10 expires: never
252 (1). FooBar (Not for a production use)
256 pub 1024D/514D0EF4 created: 2003-12-08 expires: never trust: u/u
257 sub 1024g/88480126 created: 2003-12-08 expires: never
258 sub* 1024R/E5FFF9CD created: 2003-12-08 expires: 2003-12-09
259 sub* 1024R/9A8AA276 created: 2003-12-10 expires: never
261 (1). FooBar (Not for a production use)
263 expireなどの一定のコマンドは一つの鍵のみが選択されている必要があります。