diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-06-23 09:12:07 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-06-23 09:12:07 -0300 |
commit | f205053e9e705ecb26728afc3df362f52be2d905 (patch) | |
tree | a8592bba51c1e89e69d1508ff0368be8413cbc33 /share | |
parent | e92730e128b22c70e9acb6b41c6cd6da790e7080 (diff) | |
download | hydra-f205053e9e705ecb26728afc3df362f52be2d905.tar.gz hydra-f205053e9e705ecb26728afc3df362f52be2d905.tar.bz2 |
Import keys: ssh support
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 |