Last active
April 17, 2018 13:54
-
-
Save addomafi/3788c5e27c07f738fe9c2649b0ce365c 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 | |
users=$1 | |
sudoers=$2 | |
for user in $users; do | |
set -- `echo $user | tr ':' ' '` | |
user=$1 | |
pem=$(echo "ssh-rsa $2" | base64 -w 0) | |
echo "Adding user ${user}" | |
adduser ${user} | |
passwd -d ${user} | |
echo "${user} ${sudoers}" >> /etc/sudoers | |
command="sudo -H -u ${user} bash -c 'cd;mkdir .ssh; chmod 700 .ssh; echo '${pem}' | base64 -d > .ssh/authorized_keys; chmod 400 .ssh/authorized_keys'" | |
eval $command | |
done | |
/tmp/add-users.sh "david.wen.viaconsulting:AAAAB3NzaC1yc2EAAAABJQAAAQEAx+fGTOJauhIrh01rOjxKAHLesgEtvjTvH1fRargabnmxDJkd9UipqrgLSqDQhc64mBjiAo9X/JBxxBj5zCWbKhG97Oq2I7ZE0B521w04ukHPaMgbNTkiuiJ2Mjk01DT7DPAFZvTZDmNPn8VgvJG97zhrxGxIMvDKqyCa7VRwQX111UqHIu1eKfVIzZ0rsMEioTxQMNCqCfoHTgcWF+pArJKwjre3RvZ2jjeGBOI+A9zhNH6vBKbh/G80uyFY4ndb9ya49Zh0HgK2a1onp/vYAeHMlOamDh9gq7a7AAKhhrKFyk+BEWkOJAiuyNNV+pjJopd7HAfKl7YYUx2zfKcBww== lucas.oliveira.viaconsulting:AAAAB3NzaC1yc2EAAAABJQAAAQEAkPQ2A+eu5l3r1+iSRlJzYBMTjg4qB51O2BIICE2ZTcw5xUSUoeos5iQS307FDm7RLrjdvRHVPJGgM9lJVcTpylv0dZgh1AaIEJXcZ0vpflkvfG3nj11ccbuKDpwBByRqvTZTY78wAhx7YtVyAb0jnoA684QzlJ8F+Dn4t+uqLUPivFTRoe6aT+b+02eTAEsPXhFJpHx0y6SufKAH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cfeDWJSif2miC93WuZqsAvWs9mfEPnh/Ln03VeVEk5QVg6UMO7D1W0meaz8KJQINEnSHxOnu2HAqB/Bq8RxkQ/M60H63lH6vhXCRFcKcXKrVkkgi5sSd7xfgG+pL45qct1tAO9cNSw30TFnH/pf07D77Zyz09TwB41LJkvUqIG5pycu3iQYpZSwAL/qHRmuxfiRmTvSNq7xQhLLUh9/oKLfWsXQ== marcell.biemann.viaconsulting:AAAAB3NzaC1yc2EAAAABJQAAAQEAo6O2NR4Y73OvXAs/dhPWWcHKsBD+M5vquv72KSqXn2ROT+jsDf3olhT2aHzZKr4QwvbqkjjsmDiPr0MD088Iqdvn4hy+ePerH142g+gGTDszTfK31AlRQSbruXUN6TN50X8+1r+Y2/dszmHwtfq0QWW9C//P1LgB7vtvoZjrvCG1RWDOs/jlKlDfq9iRgu7ya53fTuxvSi12ycuhyYfPKSvONnkixsonZYuFTQq7CHvixjis89aDiTwV1rMEBJFlAh3wHpShAK/CZORdW2DGQFAW3aEv0BIKtusBj9czdqINEu9fPcBVEbFVwI6t2YW1SvA5/jYLQksFN2HC9q3pjQ== victor.cezar.viaconsulting:AAAAB3NzaC1yc2EAAAABJQAAAQEAmCYvYa9zq4jAhjBMwbEka9LtKt6Zg8jHa57hXiIP/y3s5LuofGEJMGn6qVmEM/lmQLYpH1RCG0hhoR92JLQCqP4Nw3sK8umotef8PNY8l+Xy017A3EsNT8wKMg0a9QdEFTooU28NxOgPenFrlemDU2jn6CIZ8zHRTHoxpXnFZWlfEhV91VrzYfwCrCefiZP+eqbEImpHzmvS1LtXOPi0b0Olu+s+9XwgYKERO/HlSB0mkBwXyo68bOkglKACrf+QaE6hbiT21WTl6A+v9cuV8jXh+mzSxmkT1F2ifKaU6IKrrikwOYr2zqumR4gy3sE2idiZxE6t11dfNTaD0WK4sw==" "ALL=(obiee) NOPASSWD: /bin/bash" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment