Skip to content

Instantly share code, notes, and snippets.

@asimzeeshan
Last active January 2, 2022 21:23
Show Gist options
  • Save asimzeeshan/bcd64ee64c00138d58f51650fbe53be6 to your computer and use it in GitHub Desktop.
Save asimzeeshan/bcd64ee64c00138d58f51650fbe53be6 to your computer and use it in GitHub Desktop.
Add my SSH keys (cloud-init)
#!/usr/bin/bash
# My Keys
SK_ME="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC7LltfwoFD2SwG2/gu1pMKaC4fvAsgAYpKIMgig8etvWb4BwDtx5j+QVAcm+PO0ryJPys2sGlXO5z6b4y+9NPTICcx+h617xxl+Ov7HKEIH5I3BUK8kBnrn6Xt4aPKcQbDyZAgh4d0vJ/ZA3SzIxC7OgVKcc9VNpP7YJlj44JyTBvBpLlRMSLrwGoULf6OtCsDLbfIGdAwyQrj0fC6p3sPG4li0SoLiUlt6MN2/VZQX/2VSOP75I2obRrXNKNtpsRyBa5H5IPlgRcYnJ5AGJyZ/ExN0pIhAa/Z/knwlrW5oWFFYN3slMwH11uti2MdFIpBjxRhlDhIFi37ljkJa8cqUDUXknjig95kaj1xLz+DiUwpJiHaP/VHXyMPFsLp9Q0jICGvocSvVvWKc2fGYghRShGbswK87xAN9kmT/+dUu5rt7q2QKJ6bn9h13ZVO4RVdZXXkzAbglJxEE26rWDlVKrtRchUQgWi6RNOdkK47lEE/qoyjuc88uCPjv1JGR2BlLfYc+8rt8NuwCgDrE30PrDlibZ6qweQCQ1ZrCO+FCRQMcQLcZDqG1nBPwmOcsiVIgH8ANLIOCuL+P6+TZwQIH2OX4VJPpxge30ambqpfClU9s5c1uOn0Njuoy8yRRyp6i3mB6GaVdSoq25wh4if0nAkWd3mBx/71kesRV9zs9Q== [email protected]"
SK_BO="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCUOIEtlbuR2b5r4FYa/K0QLbel+WhE97DkBK2/Pejp97iLkHthxganpYCUCjnODDyJv2a1Xvwrxo3Bmj+HVBVs4+bw22nPNfhd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I3nj8/sQmmUc2QE4ogh7or8TJHVRRONMIWIyNPzk6TLXV0DiwxnOdXXrav1SLN+VNtr6wBTxyqKwj8NZ5j+XA+U13udkYzbTUTrmxTKdU8ayiECHM8qF1pPHPkENjHBtNUMce3Q9oxjVVkmXVkUyGHG/uQSWfFa4yEsxJ3WyFehUtaFBB+cDxSS3geVm1OEObSqc9iLqi88mXLwsaKoTMNPixhoX+UTw== ansible.dmzng.com"
# Do it for root user
echo $SK_ME >> /root/.ssh/authorized_keys
echo $SK_BO >> /root/.ssh/authorized_keys
echo $SK_ANSIBLE >> /root/.ssh/authorized_keys
# if user is Debian
echo $SK_ME >> /home/debian/.ssh/authorized_keys
echo $SK_BO >> /home/debian/.ssh/authorized_keys
echo $SK_ANSIBLE >> /home/debian/.ssh/authorized_keys
# if user is Ubuntu
echo $SK_ME >> /home/ubuntu/.ssh/authorized_keys
echo $SK_BO >> /home/ubuntu/.ssh/authorized_keys
echo $SK_ANSIBLE >> /home/ubuntu/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment