puppet-fdio: add check for existance of ssh key before generating new one 09/3909/1
authorFeng Pan <fpan@redhat.com>
Mon, 21 Nov 2016 19:28:23 +0000 (14:28 -0500)
committerFeng Pan <fpan@redhat.com>
Mon, 21 Nov 2016 19:28:23 +0000 (14:28 -0500)
Change-Id: I69fca1d480e2f89e059f29aeef681ae63e9796d3
Signed-off-by: Feng Pan <fpan@redhat.com>
jjb/puppet-fdio/puppet-fdio.yaml

index 4f0de02..d34f2c1 100644 (file)
     name: allow-local-ssh-root
     builders:
       - shell: |
-          #!/bin/bash
           echo "" | sudo tee -a /etc/ssh/sshd_config
           echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
           echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
           echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
           echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
           mkdir -p .ssh
-          ssh-keygen -f ~/.ssh/id_rsa -b 2048 -P ""
+          if [ ! -f ~/.ssh/id_rsa ]; then
+              ssh-keygen -f ~/.ssh/id_rsa -b 2048 -P ""
+          fi
           sudo mkdir -p /root/.ssh
           cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
           if [ -f /usr/bin/yum ]; then