]> gitweb.fluxo.info Git - hydra.git/commitdiff
Import keys: ssh support
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 23 Jun 2016 12:12:07 +0000 (09:12 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 23 Jun 2016 12:12:07 +0000 (09:12 -0300)
share/hydra/import-keys

index 00dc1034c885116eae74e23bad9cd56ef04b3364..09c5a5c3ff8838f25d51263c8b48db0069b67184 100755 (executable)
@@ -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