Scalr Script- Authorize Public Keys on Your EC2 Instances | NetEngine

Scalr Script- Authorize Public Keys on Your EC2 Instances

Tim Tuesday, 10 May 2011

Scalr has a neat ‘Scripts’ feature that allows you to attach shell scripts to various events that occur on an instance, such boot complete, persistent storage is mounted, master databases change, before instances are terminated, etc.

Scalr comes prebuilt with a selection of useful scripts, such as “Install FTP” & “MySQL Backup”, as well as other script useful in deployment, such as “svn checkout” and “git clone”.

You can also write and run your own script from the scalr interface, passing in script parameters via the GUI.

One thing we found ourselves repeatedly doing, especially during our farm configuration phase, was appending keys to user’s authorized keys files. The /root/.ssh folder is not bundled with the server image, so each time a new server instance spins up, we have no root access other than via the scalr control panel. To make the process a little easier we wrote a script to automatically append ssh public keys to a specified user’s .ssh/authorized_keys file.

This script takes:

username (eg 'ubuntu’, 'root’) public ssh key (you can modify script to insert your own default key) file (default: /home/$USER/.ssh/authorized_keys) Load this as a new script in scalr, edit to fit your needs, select a running instance and then run the script with desired parameters.

comments powered by Disqus