summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2021-11-05 18:25:19 +0100
committerTom Barrett <tom@tombarrett.xyz>2021-11-05 18:25:19 +0100
commit9345d2e524f2c40e8ec25134d0c2daa7dd2e324d (patch)
treee7fb7810b632eb2d4a505fe9906e4b722cbc13c2
parent682772eff6828cd15a73535d5a82d7e5edd643ed (diff)
parenta558da80a67c0a3496a7eb7e97f39e7118697ef5 (diff)
Merge branch 'master' of https://git.tendi.es/tom/rc
-rwxr-xr-xscripts/ssh-lxd9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/ssh-lxd b/scripts/ssh-lxd
new file mode 100755
index 0000000..b4bf2fe
--- /dev/null
+++ b/scripts/ssh-lxd
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+IP=$(lxc ls -fcsv | grep $1 | tr ' ' , | cut -d, -f3)
+if ! ssh -o BatchMode=yes root@$IP; then
+ lxc exec $1 -- bash -c "mkdir -p /root/.ssh && \
+ echo \"$(ssh-add -L)\" \
+ > /root/.ssh/authorized_keys"
+ ssh root@$IP
+fi