Last active
September 7, 2016 21:52
-
-
Save greg-1-anderson/99db95048bcbb7580a9fdb73cc5ad629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Add the ssh key for the specified Pantheon site and environment | |
# to the user's known_hosts file. | |
# | |
# See: http://serverfault.com/questions/132970/can-i-automatically-add-a-new-host-to-known-hosts | |
# | |
# Note that this script does not remove and re-add the ssh keys; | |
# if you want to do that, you might as well just use -o StrictHostKeyChecking=no. | |
# | |
SITE="$1" | |
ENV="$2" | |
SITE_ID=$(terminus site info --site="$SITE" --field=id) | |
grep -q appserver.$ENV.$SITE_ID.drush.in ~/.ssh/known_hosts | |
if [ $? == 0 ] | |
then | |
echo "appserver.$ENV.$SITE_ID.drush.in already known" | |
exit 0 | |
fi | |
ssh-keyscan -p 2222 appserver.$ENV.$SITE_ID.drush.in >> ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment