Skip to content

Commit 1bf5cc6

Browse files
committed
Logically separate examples, add content
1 parent c4e35c9 commit 1bf5cc6

File tree

4 files changed

+84
-68
lines changed

4 files changed

+84
-68
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
* [Bash tips](./sub/bash.md)
44
* [Encryption, signatures, keys](./sub/enc.md)
5-
* [SSH tunnel recipes](./sub/ssh-tunnel.md)
5+
* [SSH recipes](./sub/ssh.md)
66
* [Process text files](./sub/edit-process-text.md)
77
* [Work with files and filesystems](./sub/files.md)
8-
* [Pretty code distribution (enscript)](./sub/enscript.md)
8+
* [Pretty code distribution (enscript)](./sub/code-enscript.md)
File renamed without changes.

sub/enc.md

+16-65
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,6 @@
1-
# Encryption, signatures, keys
1+
# openssl
22

3-
## SSH
4-
5-
### Generate new keypair
6-
7-
```bash
8-
ssh-keygen -t rsa -a 100 -b 8192
9-
```
10-
11-
Alternatively (though RSA 8192 _might_ be safer):
12-
```bash
13-
ssh-keygen -t ed25519 -a 100
14-
```
15-
16-
## Display key signature and artwork
17-
18-
```bash
19-
ssh-keygen -vl -f privkey
20-
```
21-
22-
## Create a public key from a private key
23-
24-
```bash
25-
ssh-keygen -y -f privkey > pubkey
26-
```
27-
28-
## Change (or add) passphrase for private key
29-
30-
```bash
31-
ssh-keygen -p -f privkey
32-
```
33-
34-
## Convert OpenSSH private key to RSA private key
35-
36-
```bash
37-
# This operation overwrites the privkey file
38-
cp privkey privkey.openssh
39-
ssh-keygen -p -N "" -m pem -f privkey
40-
```
41-
42-
## Convert public key to Windows-friendly
43-
44-
You're not really using Windows, right? This is for your less-fortunate acquaintances.
45-
46-
```bash
47-
ssh-keygen -e -m RFC4716 -f pubkey > pubkey.otherformat
48-
```
49-
50-
## openssl
51-
52-
### Prepare new x509 cert
3+
## Prepare new x509 cert
534

545
Generate private key:
556
```bash
@@ -66,7 +17,7 @@ Self-sign cert (or.. submit the CSR to your CA instead):
6617
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.pem
6718
```
6819

69-
### Inspect
20+
## Inspect
7021

7122
View PEM cert contents:
7223
```bash
@@ -93,7 +44,7 @@ View CSR contents:
9344
openssl req -text -noout -verify -in server.csr
9445
```
9546

96-
### Verify
47+
## Verify
9748

9849
Verify cert chain:
9950
```bash
@@ -106,7 +57,7 @@ openssl x509 -noout -modulus -in server.pem | openssl sha1
10657
openssl rsa -noout -modulus -in server.key | openssl sha1
10758
```
10859

109-
### Create password digests
60+
## Create password digests
11061

11162
md5 digest:
11263
```bash
@@ -118,7 +69,7 @@ sha512 digest:
11869
openssl passwd -salt xxyyzz -6 'nicer.pass'
11970
```
12071

121-
### Create Java keystore
72+
## Create Java keystore
12273

12374
```bash
12475
# First, convert PEM file and key to PKCS12 format
@@ -156,50 +107,50 @@ keytool \
156107
-file some-other-ca.pem
157108
```
158109

159-
### View Java keystore
110+
## View Java keystore
160111

161112
```bash
162113
keytool -list -v -keystore server.jks -storepass 'JKS password'
163114
```
164115

165-
## tcpdump
116+
# tcpdump
166117

167-
### Confirm encryption on the wire
118+
## Confirm encryption on the wire
168119

169120
Note: to capture the full packet payload, the `-s 0` option was required on older tcpdump versions. It is no longer necessary.
170121

171122
```bash
172123
sudo tcpdump -i ens160 -nn -A port 3306 and host 10.69.80.2
173124
```
174125

175-
### Save packet capture to file
126+
## Save packet capture to file
176127

177128
```bash
178129
sudo tcpdump -i ens160 -w foo port 3306 and host 10.69.80.2
179130
```
180131

181-
### Read packet capture data from file
132+
## Read packet capture data from file
182133

183134
```bash
184135
tcpdump -nn -A -r foo
185136
```
186137

187-
## GNUPG
138+
# GNUPG
188139

189-
### Create a new keypair
140+
## Create a new keypair
190141

191142
```bash
192143
gpg --full-gen-key --expert
193144
```
194145

195-
### Import public key
146+
## Import public key
196147

197148
```bash
198149
# Example keyserver and key ID..
199150
gpg --keyserver pgp.mit.edu --recv-keys 89ccae8b
200151
```
201152

202-
### Back up and restore a keypair
153+
## Back up and restore a keypair
203154

204155
This is a cleaner approach than exporting the public key, private key, and trustdb separately
205156

@@ -219,7 +170,7 @@ gpg> trust
219170
gpg> quit
220171
```
221172

222-
## Steganography
173+
# Steganography
223174

224175
Both `steghide` and `outguess` are decent options.
225176

sub/ssh-tunnel.md renamed to sub/ssh.md

+66-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,69 @@
1-
# SSH tunnel recipes
1+
# SSH key magic
2+
3+
## Generate new keypair
4+
5+
RSA:
6+
```bash
7+
ssh-keygen -t rsa -a 100 -b 8192
8+
```
9+
10+
ED25519:
11+
```bash
12+
ssh-keygen -t ed25519 -a 100
13+
```
14+
15+
ED25519 with FIDO authenticator:
16+
* nonresident credentials
17+
* touch required
18+
```bash
19+
ssh-keygen -t ed25519-sk -C "Yubi-W"
20+
```
21+
22+
ED25519 with FIDO authenticator: [^yubi_example]
23+
* resident credentials
24+
* PIN required
25+
```bash
26+
ssh-keygen -t ed25519-sk -O resident -O verify-required -C "Yubi-SB"
27+
```
28+
29+
[^yubi_example]:
30+
FIDO example with resident credentials derived from [Yubikey article](https://developers.yubico.com/SSH/Securing_SSH_with_FIDO2.html).
31+
32+
## Display key signature and artwork
33+
34+
```bash
35+
ssh-keygen -vl -f privkey
36+
```
37+
38+
## Create a public key from a private key
39+
40+
```bash
41+
ssh-keygen -y -f privkey > pubkey
42+
```
43+
44+
## Change (or add) passphrase for private key
45+
46+
```bash
47+
ssh-keygen -p -f privkey
48+
```
49+
50+
## Convert OpenSSH private key to RSA private key
51+
52+
```bash
53+
# This operation overwrites the privkey file
54+
cp privkey privkey.openssh
55+
ssh-keygen -p -N "" -m pem -f privkey
56+
```
57+
58+
## Convert public key to Windows-friendly
59+
60+
You're not really using Windows, right? This is for your less-fortunate acquaintances.
61+
62+
```bash
63+
ssh-keygen -e -m RFC4716 -f pubkey > pubkey.otherformat
64+
```
65+
66+
# SSH tunneling
267

368
## Port forward
469

0 commit comments

Comments
 (0)