summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
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