Skip to content

Instantly share code, notes, and snippets.

@aduzsardi

aduzsardi/keys.sh Secret

Last active Oct 30, 2018
Embed
What would you like to do?
my keys
#!/bin/bash
#
# Adauga key-ile ssh sysadmini in 'authorized_keys' al utilizatorului cu care rulat
# 'curl keys.mydomain.com | bash'
# Adauga key-a ssh in lista de mai jos
KEYS="
# -- Sysadmins SSH Keys --
# - user 'sysadmin' va fi folosit in viitor pentru chestii de administrare & monitorizare pe VM-uri
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAA... sysadmin@odin
# - aduzsardi rsa key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9f0D4QM8Y3KHnZg15nV39OmsTSSRz5k8tcPljX8Rk5dYHTda3lyNT... aduzsardi@home
# - aduzsardi ecdsa key
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGe= alexandru.duzsardi@home
# -- Sysadmins SSH Keys --
"
authorized_keys="${HOME}/.ssh/authorized_keys"
echo "Adaug key-ile ssh pentru root login"
if [[ -a "$authorized_keys" ]]; then
echo "Fisierul '$authorized_keys' exista"
echo "Adaug key-ile ssh"
echo "$KEYS" >> "$authorized_keys"
else
echo "Fisierul '$authorized_keys' nu exista"
echo "Creez fisierul acum"
mkdir ${HOME}/.ssh; chmod 700 ${HOME}/.ssh
echo "Adaug key-ile ssh"
echo "$KEYS" > "$authorized_keys"
chmod 600 "$authorized_keys"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment