diff options
author | Tom Barrett <tom@tombarrett.xyz> | 2021-10-28 19:39:54 +0200 |
---|---|---|
committer | Tom Barrett <tom@tombarrett.xyz> | 2021-10-28 19:39:54 +0200 |
commit | a558da80a67c0a3496a7eb7e97f39e7118697ef5 (patch) | |
tree | eebb6e6e1f6064e39493bb07d9d21ae27d130e28 /scripts/ssh-lxd | |
parent | 3bb813427f123aec4ded40d06a3c8684a9d41140 (diff) |
helpful
Diffstat (limited to 'scripts/ssh-lxd')
-rwxr-xr-x | scripts/ssh-lxd | 9 |
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 |