add install files (just add credentials)

This commit is contained in:
Emil Lerch 2019-07-15 17:28:24 -07:00
parent d58b9048c9
commit a5ea5c2350
Signed by: lobo
GPG Key ID: CEC5F37C1BE5A481
4 changed files with 33 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.credentials

3
config Normal file
View File

@ -0,0 +1,3 @@
[default]
region = us-west-2
output = json

12
get_authorized_keys Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Accomodate for local install
PATH=$HOME/.local/bin:$PATH
aws codecommit get-file \
--repository-name authorized_keys \
--file-path authorized_keys \
--query 'fileContent' \
--cli-read-timeout 1 \
--cli-connect-timeout 1 \
--output text |base64 -d

17
makeitso Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
sudo adduser --disabled-login --gecos 'User for AuthorizedKeysCommand' authorizedkeysuser
sudo sh -c "echo 'AuthorizedKeysCommand /etc/ssh/get_authorized_keys
AuthorizedKeysCommandUser authorizedkeysuser' >> /etc/ssh/sshd_config"
sudo cp authorized_keys /etc/ssh
sudo chmod 755 /etc/ssh/get_authorized_keys
sudo -u authorizedkeysuser mkdir ~authorizedkeysuser/.aws
sudo -u authorizedkeysuser cp config ~authorizedkeysuser/.aws
sudo -u authorizedkeysuser cp .credentials ~authorizedkeysuser/.aws/credentials
sudo -u authorizedkeysuser chmod 600 ~authorizedkeysuser/.aws/*
sudo -u authorizedkeysuser sh -c 'command -v aws > /dev/null 2>&1 || pip install --user awscli'
sudo systemctl restart sshd