forked from backube/volsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-keys.sh
executable file
·47 lines (38 loc) · 982 Bytes
/
make-keys.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/bash
set -e -o pipefail
# We always use RSA keys since the other types are either insecure or not
# available in FIPS mode
SOURCE=source-key
DESTINATION=destination-key
function gen-key {
OUTFILE="$1"
rm -f "$OUTFILE" "$OUTFILE.pub"
ssh-keygen -q -t rsa -b 4096 -f "$OUTFILE" -C '' -N ''
}
gen-key "$SOURCE"
gen-key "$DESTINATION"
cat - <<SOURCE > source-secret.yaml
---
apiVersion: v1
kind: Secret
metadata:
name: source-secret
type: Opaque
data:
source: $(base64 -w0 < "$SOURCE")
source.pub: $(base64 -w0 < "$SOURCE.pub")
destination.pub: $(base64 -w0 < "$DESTINATION.pub")
SOURCE
cat - <<DESTINATION > destination-secret.yaml
---
apiVersion: v1
kind: Secret
metadata:
name: destination-secret
type: Opaque
data:
source.pub: $(base64 -w0 < "$SOURCE.pub")
destination: $(base64 -w0 < "$DESTINATION")
destination.pub: $(base64 -w0 < "$DESTINATION.pub")
DESTINATION
rm -f "${SOURCE}" "${SOURCE}.pub" "${DESTINATION}" "${DESTINATION}.pub"