]> gitweb.fluxo.info Git - hydra.git/commitdiff
Key generation / import improvements
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 8 Sep 2015 20:42:04 +0000 (17:42 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 8 Sep 2015 20:42:04 +0000 (17:42 -0300)
share/hydra/import-key
share/hydra/newkeys

index f394f8c309542994f451a4286c626c9d7905a342..8929bafa64564fbd5b7f39cd56f4c7479b415f0d 100755 (executable)
@@ -44,20 +44,24 @@ for node in $NODES; do
     continue
   fi
 
+  $HYDRA_CONNECT $node <<EOF
+  ##### BEGIN REMOTE SCRIPT #####
   echo ""
   echo "-----------------------------"
   echo "Importing gpg key to $node..."
   echo "-----------------------------"
   echo ""
-  echo "$key" | $HYDRA_CONNECT $node sudo gpg --homedir /root/.gnupg --import
+  echo "$key" | sudo gpg --homedir /root/.gnupg --import
 
   echo ""
   echo "Trusting key at $node..."
   echo ""
-  printf "trust\n5\ny\nsave\n" | $HYDRA_CONNECT $node sudo gpg --homedir /root/.gnupg --no-tty --status-fd=2 --command-fd=0 --edit-key $key_id
+  printf "trust\n5\ny\nsave\n" | sudo gpg --homedir /root/.gnupg --no-tty --status-fd=2 --command-fd=0 --edit-key $key_id
 
   echo ""
   echo "Verifying..."
   echo ""
-  $HYDRA_CONNECT $node sudo gpg --homedir /root/.gnupg --list-keys
+  sudo gpg --homedir /root/.gnupg --list-keys
+  ##### END REMOTE SCRIPT #######
+EOF
 done
index c46a80932fa832174235cfd790be678b9a050ff0..37e76e80a39d5ad2e4512ca8cd9dcb661a995946 100755 (executable)
@@ -21,8 +21,8 @@ function hydra_newkeys {
   # GPG keys should be manually imported in the nodes
   for host in `hydra $HYDRA nodes`; do
     node="`echo $host | cut -d . -f 1`"
-    privkey="$PUPPET_KEYS/ssh/$node/"$node"_id_rsa"
-    pubkey="$privkey.pub"
+    sshkey="$HYDRA_FOLDER/keyring/keys/nodes/$node/ssh/id_rsa.asc"
+    gpgkey="$HYDRA_FOLDER/keyring/keys/nodes/$node/gpg/key.asc"
     if [ "$1" == "all" ]; then
       hydra_genpairs
     elif [ "$1" == "all-ssh" ]; then
@@ -32,7 +32,7 @@ function hydra_newkeys {
     elif [ ! -z "$1" ] && [ "$node" == "$1" ]; then
       hydra_genpairs $2
       exit $?
-    elif [ ! -e "$privkey" ] || [ ! -e "$pubkey" ]; then
+    elif [ ! -e "$sshkey" ] || [ ! -e "$gpgkey" ]; then
       hydra_genpairs
     fi
   done
@@ -42,7 +42,6 @@ function hydra_genpairs {
   BASEDIR="/tmp"
 
   if [ "$1" != "pgp" ]; then
-    #keyringer $HYDRA genpair ssh nodes/$node/ssh/id_rsa $host $privkey
     keyringer $HYDRA genpair ssh nodes/$node/ssh/id_rsa $host
   fi
 
@@ -57,12 +56,6 @@ function hydra_genpairs {
   keyringer $HYDRA git push
 
   hydra_unset_tmpfile $TMPWORK
-
-  # Add key into puppet git repository.
-  #( cd $PUPPET_KEYS/ssh/$node && git add $(basename $privkey) $(basename $pubkey) )
-
-  # Sync pubkeys folder
-  #( cd $PUPPET_KEYS/public && find ../ssh/ -maxdepth 2 -name '*.pub' -exec cp {} . \; && git add . )
 }
 
 # Load.