summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2021-10-28 19:39:54 +0200
committerTom Barrett <tom@tombarrett.xyz>2021-10-28 19:39:54 +0200
commita558da80a67c0a3496a7eb7e97f39e7118697ef5 (patch)
treeeebb6e6e1f6064e39493bb07d9d21ae27d130e28 /scripts
parent3bb813427f123aec4ded40d06a3c8684a9d41140 (diff)
helpful
Diffstat (limited to 'scripts')
-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