Skip to content

Instantly share code, notes, and snippets.

@felixrabe
Created July 2, 2014 18:15
Show Gist options
  • Save felixrabe/432eb8427a800aee9b55 to your computer and use it in GitHub Desktop.
Save felixrabe/432eb8427a800aee9b55 to your computer and use it in GitHub Desktop.
Cyon Geekserver Provisionin Scaffold
#!/usr/bin/env bash
# Written by Felix Rabe (rabe.io).
# Hereby placed in the Public Domain. Use however you wish.
if [[ $# -eq 0 ]] ; then
echo "This script is for provisioning a Cyon Geekserver that has"
echo "been set up using Ubuntu 14.04. ONLY USE FOR A NEW SERVER!"
echo
echo "Usage example:"
echo " ./provision.sh vsg-xxxxxx.cyoncloud.com"
echo
echo "The script will only ask for the root password once."
exit 0
fi
HOST=$1
## This script is based on:
## http://theholyjava.wordpress.com/2010/09/10/ssh-magic-authorize-only-once-for-multiple-sshscp-invocations/
USER_AT_HOST="root@$HOST"
SSHSOCKET=~/".ssh/$USER_AT_HOST"
## 1. Open the master connection
echo "AUTHENTICATE ONCE"
echo
ssh -M -f -N -o ControlPath="$SSHSOCKET" "$USER_AT_HOST"
## 2. Open and close other connections without re-authenticating
# scp -o ControlPath="$SSHSOCKET" "$USER_AT_HOST":remoteFile.txt ./
ssh -o ControlPath="$SSHSOCKET" "$USER_AT_HOST" "echo hello"
ssh -o ControlPath="$SSHSOCKET" "$USER_AT_HOST" "echo world"
## 3. Close the master connection
ssh -S "$SSHSOCKET" -O exit "$USER_AT_HOST"
echo
echo ":: DONE ::"
echo
echo "Server is now ready to host Docker images."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment