A method for managing and giving team members access to remote servers without needing to pass around the master .pem
key. Generates and sends authorized key files to a list of hosts based on a set of permissions.
Generates a new keys/*.txt
file for each user defined in permissions.txt
when one doesn't already exist. Gets the list by calling out to https://github.com/<user>.keys
. After first fetching a set of keys, the list can be paired down if necessary before running upload_keys.sh
.
./fetch_keys_from_github.sh
- Runs through each group defined in
hosts/
. ex: - Reads the
permissions.txt
file to find out which users have permission to that host - Generates a master authorized keys file for those users using their keys from
keys/<user>.txt
- Uploads it to
~/.ssh/authorized_keys_sh
for each host in that group. This avoids overwriting the server defaultauthorized_keys
file.
./upload_keys.sh
Specifies each user and which groups of hosts they should have permissions for. The format for each line is a GitHub username followed by a dash, then a comma-delimited list of groups they belong to. Each group should correspond to a file with a list of servers in hosts/
. Example below:
ifightcrime - web,mygroup,othergroup
This directory houses a user specific set of keys for each user defined in permissions.txt
.
Each file (group) contains a list of associated hosts that we want to push the keys to. A separate user@host
is defined on each line.
Modify the host's /etc/ssh/sshd_config
file to add support for our new authorized_keys_sh
file. Change the AuthorizedKeysFile
directive to match the following (and uncomment if commented):
AuthorizedKeysFile %h/.ssh/authorized_keys %h/.ssh/authorized_keys_sh
Don't forget to reload ssh after you make the change.
/etc/init.d/ssh reload