@@ -44,13 +44,14 @@ in the GitHub Docs.
44
44
45
45
#### Using a subkey from an existing GPG key
46
46
47
- First open your master key for editing:
47
+ First open your master key for editing (use ` --list-keys ` to find it) :
48
48
49
49
``` bash
50
50
gpg --edit-key " <YOUR MASTER KEY ID>"
51
51
```
52
52
53
- Type ` addkey ` and select signing or s for capabilities. RSA key type is recommended for greatest compatibility.
53
+ Type ` addkey ` and select a type that is for signing, you might be asked about bit size depending on your choice.
54
+ When deciding over key expire, avoid setting to never expire, as recommendation of key bits will change over time.
54
55
Type ` save ` to persist the new subkey to your master key. Make a note of the Key ID as you will need it in the next step.
55
56
56
57
Next export the new sub key:
@@ -69,41 +70,42 @@ You can skip this if your master key is not password protected.
69
70
To remove the password from the subkey, create an ephemeral gpg home directory:
70
71
71
72
``` bash
72
- mkdir /tmp/ gpg
73
+ install -d -m 700 gpg-tmp
73
74
```
74
75
75
76
Ensure that it works with gpg:
76
77
77
78
``` bash
78
- gpg --homedir /tmp/ gpg --list-keys
79
+ gpg --homedir gpg-tmp --list-keys
79
80
```
80
81
81
- You can ignore the warning about unsafe directory permissions.
82
-
83
82
Import your subkey:
84
83
85
84
``` bash
86
- gpg --homedir /tmp/ gpg --import private.key
85
+ gpg --homedir gpg-tmp --import private.key
87
86
```
88
87
89
88
Enter edit mode:
90
89
91
90
``` bash
92
- gpg --homedir /tmp/ gpg --edit-key < SubKey ID>
91
+ gpg --homedir gpg-tmp --edit-key < SubKey ID>
93
92
```
94
93
95
94
Type ` passwd ` , entering your current password and then set the password to "" to remove it.
96
95
96
+ The command may give error ` error changing passphrase: No secret key ` when setting empty password.
97
+ You should ignore it as the password was really removed.
98
+
97
99
Type ` save ` to exit edit mode and re-export your subkey:
98
100
99
101
``` bash
100
- gpg --homedir /tmp/ gpg --output private.key --armor --export-secret-subkeys " <SubKey ID>!"
102
+ gpg --homedir gpg-tmp --output private.key --armor --export-secret-subkeys " <SubKey ID>!"
101
103
```
102
104
103
105
Finally, remove the ephemeral directory:
104
106
105
107
``` bash
106
- rm --rf /tmp/ gpg
108
+ rm --rf gpg-tmp
107
109
```
108
110
109
111
You will now need to export your master public key with the new subkey public key to the file ` public.key ` :
0 commit comments