summaryrefslogtreecommitdiff
path: root/set-authorized-key
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-04-09 20:33:59 +0300
committerLars Wirzenius <liw@liw.fi>2020-04-09 20:33:59 +0300
commitcda17c670a9a8296d840cbe7e55721b8df776d39 (patch)
tree0a33569ab2ab869e36eb2ef3bf71af460258d54f /set-authorized-key
parent1ccd927743cb1c6d13b6b30e4a598d1d97d51f9c (diff)
downloadick-contractor-cda17c670a9a8296d840cbe7e55721b8df776d39.tar.gz
Add: script to set manager's authorized_keys
Diffstat (limited to 'set-authorized-key')
-rwxr-xr-xset-authorized-key19
1 files changed, 19 insertions, 0 deletions
diff --git a/set-authorized-key b/set-authorized-key
new file mode 100755
index 0000000..b74eb2f
--- /dev/null
+++ b/set-authorized-key
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -eu
+
+img="$1"
+pubkey="$2"
+
+undo() {
+ umount --force "$tmp" || true
+ rmdir "$tmp"
+ kpartx -dsv "$img"
+}
+
+trap undo EXIT
+tmp="$(mktemp -d)"
+
+dev="/dev/mapper/$(kpartx -asv "$img" | awk '{ print $3 }')"
+mount "$dev" "$tmp"
+cp "$pubkey" "$tmp/home/manager/.ssh/authorized_keys"