Debian Codegraph @

scripts/kxc-add-key

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 #
3 # Add a new key to kxc's configuration (initializing it if necessary).
4 #
5 # If /etc/kxc is missing, this script creates it, as well as the required
6 # client certificates.
7 #
8 # Then, it adds configuration for fetching a given key.
9
10 set -e
11
12 SERVER="$1"
13 KEYNAME="$2"
14
15 if [scip-shell system . . `[`. "$SERVER" = "" ] || [scip-shell system . . `[`. "$KEYNAME" = "" ]; then
16 echoscip-shell system . . echo. "
17 Usage: kxc-add-key <server hostname> <key name>
18
19 This command adds a new key to kxc's configuration, initializing it if
20 necessary.
21 "
22 exit 1
23 fi
24
25
26 # Create the base configuration directory.
27 echoscip-shell system . . echo. "Creating directories (/etc/kxc/)"
28 mkdirscip-shell system . . mkdir. -p /etc/kxc/scip-shell filesystem . . `/etc/kxc/`.
29
30 # Create a private key for the client.
31 if ! [scip-shell system . . `[`. -e /etc/kxc/key.pemscip-shell filesystem . . `/etc/kxc/key.pem`. ]; then
32 kxgencert \
33 -organization "kxc@$HOSTNAME" \
34 -key /etc/kxc/key.pemscip-shell filesystem . . `/etc/kxc/key.pem`. \
35 -cert /etc/kxc/cert.pemscip-shell filesystem . . `/etc/kxc/cert.pem`.
36 chmodscip-shell system . . chmod. 400 /etc/kxc/key.pemscip-shell filesystem . . `/etc/kxc/key.pem`.
37 else
38 echoscip-shell system . . echo. "Private key already exists (/etc/kxc/key.pem)"
39 fi
40
41 echoscip-shell system . . echo. "Setting URL to kxd://$SERVER/$HOSTNAME/$KEYNAME"
42 echoscip-shell system . . echo. "kxd://$SERVER/$HOSTNAME/$KEYNAME" > "/etc/kxc/${KEYNAME}.url"
43
44 echoscip-shell system . . echo.
45 echoscip-shell system . . echo.
46 echoscip-shell system . . echo. "YOU need to copy the server certificate to"
47 echoscip-shell system . . echo. "/etc/kxc/${KEYNAME}.server_cert.pem. For example, using:"
48 echoscip-shell system . . echo.
49 echoscip-shell system . . echo. " $ scp $SERVER:/etc/kxd/cert.pem /etc/kxc/${KEYNAME}.server_cert.pem"
50 echoscip-shell system . . echo.