use sudo -E to preserve env vars
set -ex
mkdir -p ~/.ssh
-# what is messing up $HOME?
-sudo grep -ri ENV /etc/sudoers*
# Generate ssh keys on StackStorm box and copy over public key into remote box.
ssh-keygen -f ~/.ssh/st2_id_rsa -P ""
+# sudo -E = preserve HOME var
# Authorize key-base acces
-sudo bash -xc "cat ~/.ssh/st2_id_rsa.pub >> ~/.ssh/authorized_keys"
-sudo chmod 0600 ~/.ssh/authorized_keys
-sudo chmod 0700 ~/.ssh
-sudo chown -R "${ST2_CI_USER}:${ST2_CI_USER}" ~/.ssh
+sudo -E bash -xc "cat ~/.ssh/st2_id_rsa.pub >> ~/.ssh/authorized_keys"
+sudo -E chmod 0600 ~/.ssh/authorized_keys
+sudo -E chmod 0700 ~/.ssh
+sudo -E chown -R "${ST2_CI_USER}:${ST2_CI_USER}" ~/.ssh
