diff options
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydra/import-keys | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/share/hydra/import-keys b/share/hydra/import-keys index 00dc103..09c5a5c 100755 --- a/share/hydra/import-keys +++ b/share/hydra/import-keys @@ -54,8 +54,28 @@ EOF # Import OpenSSH keypair function hydra_import_keys_openssh { - # TODO - echo "Not implemented!" + echo "-----------------------------------------------------" + echo "Importing keypair at $hostname:/root/.ssh..." + echo "-----------------------------------------------------" + + echo "Creating folder structure at $hostname:/root/.ssh..." + $HYDRA_CONNECT $hostname <<EOF + sudo mkdir -p /root/.ssh + sudo chown root.root /root/.ssh + sudo chmod 700 /root/.ssh + sudo touch /root/.ssh/id_rsa + sudo touch /root/.ssh/id_rsa.pub + sudo chmod 600 /root/.ssh/id_rsa + sudo chmod 600 /root/.ssh/id_rsa.pub +EOF + + echo "Importing public key from keyringer to $hostname:/root/.ssh..." + keyringer $HYDRA decrypt nodes/$hostname/ssh/id_rsa.pub | \ + $HYDRA_CONNECT $hostname "cat - | sudo tee /root/.ssh/id_rsa.pub > /dev/null" + + echo "Importing private key from keyringer to $hostname:/root/.ssh..." + keyringer $HYDRA decrypt nodes/$hostname/ssh/id_rsa | \ + $HYDRA_CONNECT $hostname "cat - | sudo tee /root/.ssh/id_rsa > /dev/null" } # Command line arguments |