From 448cab6d8f073558a3f4c3a85652d3fcbf03c100 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 4 Oct 2021 18:57:00 -0400 Subject: clean up keycopy.sh somewhat (and rename it) --- keycopy.sh | 115 ------------------------------------------------------------- 1 file changed, 115 deletions(-) delete mode 100644 keycopy.sh (limited to 'keycopy.sh') diff --git a/keycopy.sh b/keycopy.sh deleted file mode 100644 index 68c97fd..0000000 --- a/keycopy.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh -yourip=68.48.18.140 -h=$yourip -n=andy - -key_basename=ssh_host_rsa_key -input_key=/etc/ssh/$key_basename - -ssh2der() -{ - ssh-keygen -e -f "$1" -m PEM | openssl rsa -RSAPublicKey_in -outform DER -} - -match_and_drop_first_word() -{ - expect=$1 - while read word rest - do - if [ "$word" = "$expect" ] - then - printf '%s\n' "$rest" - return - fi - done - false -} - -keyscan() -{ - if [ -e keyscan.cache ] - then - cat keyscan.cache - else - ssh-keyscan -t rsa "$1" - fi -} - -keycopy() -{ - openssl rsa -in "$input_key" -outform DER > /etc/swanctl/private/"$key_basename" - openssl rsa -in "$input_key" -pubout -outform DER > /etc/swanctl/pubkey/"$key_basename".pub - - t=$(mktemp) - - keyscan "$yourip" | match_and_drop_first_word "$yourip" > "$t" - ssh2der "$t" > /etc/swanctl/pubkey/"$n".pub - rm -f "$t" -} - -nocomments() -{ - sed 's/#.*//; /^ *$/d' -} - - -write_config() -{ - conn=$1 - remote_addrs=$2 - id=$3 - cat > /etc/swanctl/conf.d/"$conn".conf <