about summary refs log tree commit diff
path: root/keys
diff options
context:
space:
mode:
Diffstat (limited to 'keys')
-rwxr-xr-xkeys38
1 files changed, 38 insertions, 0 deletions
diff --git a/keys b/keys
new file mode 100755
index 0000000..d6e7029
--- /dev/null
+++ b/keys
@@ -0,0 +1,38 @@
+#!/bin/sh
+## Script for copying my keychain
+##
+## This script is supposed to sit on a removable drive with these files:
+## - id_rsa - private ssh key
+## - id_rsa.pub - public ssh key
+## - secret.gpg - private gpg key
+## - public.gpg - public gpg key
+##
+## To setup your keys mount the drive, cd into it and run `./keys`
+
+set -euo pipefail
+
+echo "\$USER is $USER; \$HOME is $HOME"
+
+[ "$USER" != "pn" ] && echo "\nWarning: username is not 'pn'!\n"
+
+read -p "continue? [y/N]" choice
+
+case "$choice" in
+  y|Y) echo "Installing..." ;;
+  * ) echo "Mission aborted!"; exit 1 ;;
+esac
+
+echo "Copying ssh key to $HOME/.ssh/id_rsa ..."
+mkdir -p $HOME/.ssh
+cp id_rsa $HOME/.ssh
+cp id_rsa.pub $HOME/.ssh
+chmod 700 $HOME/.ssh/id_rsa
+echo "Ssh key done."
+
+echo "Importing gpg keys..."
+cp public.gpg secret.gpg $HOME
+gpg --import $HOME/public.gpg
+echo "Key $HOME/public.gpg imported"
+gpg --import $HOME/secret.gpg
+echo "Key $HOME/secret.gpg imported"
+echo "Gnupg keys done"