From a558da80a67c0a3496a7eb7e97f39e7118697ef5 Mon Sep 17 00:00:00 2001
From: Tom Barrett <tom@tombarrett.xyz>
Date: Thu, 28 Oct 2021 19:39:54 +0200
Subject: helpful

---
 scripts/ssh-lxd | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100755 scripts/ssh-lxd

(limited to 'scripts/ssh-lxd')

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
-- 
cgit v1.2.3