summaryrefslogtreecommitdiff
path: root/keycopy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'keycopy.sh')
-rw-r--r--keycopy.sh53
1 files changed, 47 insertions, 6 deletions
diff --git a/keycopy.sh b/keycopy.sh
index 29f8423..f9ebbb9 100644
--- a/keycopy.sh
+++ b/keycopy.sh
@@ -4,12 +4,53 @@ n=andy
4 4
5key_basename=ssh_host_rsa_key 5key_basename=ssh_host_rsa_key
6input_key=/etc/ssh/$key_basename 6input_key=/etc/ssh/$key_basename
7openssl rsa -in "$input_key" -outform DER > /etc/swanctl/private/"$key_basename"
8openssl rsa -in "$input_key" -pubout -outform DER > /etc/swanctl/pubkey/"$key_basename".pub
9 7
10t=$(mktemp) 8keycopy()
11ssh-keyscan -trsa "$h" | while read hh rest; do [ "$h" = "$hh" ] && printf '%s\n' "$rest"; done 9{
10 openssl rsa -in "$input_key" -outform DER > /etc/swanctl/private/"$key_basename"
11 openssl rsa -in "$input_key" -pubout -outform DER > /etc/swanctl/pubkey/"$key_basename".pub
12 12
13ssh-keygen -e -f rsa.scan.edit -m PEM | openssl rsa -RSAPublicKey_in -outform DER > /etc/swanctl/pubkey/"$n".pub 13 t=$(mktemp)
14 ssh-keyscan -trsa "$h" | while read hh rest; do [ "$h" = "$hh" ] && printf '%s\n' "$rest"; done
15
16 ssh-keygen -e -f rsa.scan.edit -m PEM | openssl rsa -RSAPublicKey_in -outform DER > /etc/swanctl/pubkey/"$n".pub
17
18 ls -l /etc/swanctl/private/"$key_basename" /etc/swanctl/pubkey/"$key_basename".pub /etc/swanctl/pubkey/"$n".pub
19}
20
21nocomments()
22{
23 sed 's/#.*//; /^ *$/d'
24}
25
26
27test_old_config()
28{
29 ipsec stop
30 rm -f /etc/swanctl/conf.d/andy.conf
31 cp ipsec.conf /etc/
32 nocomments < ipsec.conf
33 ipsec start
34 sleep 2
35 ipsec listpubkeys
36 ipsec up andy
37 ipsec stop
38}
39
40test_new_config()
41{
42 ipsec stop
43 cp -T ipsec.conf.empty /etc/ipsec.conf
44 cp andy.conf /etc/swanctl/conf.d/
45 nocomments < andy.conf
46 ipsec start
47 sleep 2
48 swanctl -c
49 ipsec listpubkeys
50 ipsec up andy
51 ipsec stop
52}
53
54test_old_config
55test_new_config
14 56
15ls -l /etc/swanctl/private/"$key_basename" /etc/swanctl/pubkey/"$key_basename".pub /etc/swanctl/pubkey/"$n".pub