SSH keys managed with Salt Stack

In short, you can manage SSH keys by adding these lines to a .sls file:

AAAAB3NzaC1yc2EAAAABIwAAAQEAx2wGNnRpfzMA9+bvIEQkbHjregNzz4GSKo32eWGEOWDPnq46IOjbYF4kI7ezkS/CfYWCRluXkXT1K2Iy9WLLl4xDTV1WTC0I55PzHYdVsP8idq/lVMYSHhEgOp3fVK8+sp9WgSGkjUOgNdDok62dEmoZrE0waHrnPtkAmdG28Qiy2VH/k9HQUxl77ss70wKAfwfojslaBreD8Afi2LGAzQoZinL10csNEJTgLkU8g0ut2F0YJPNwXw3uL/mqN1dyBd2yZuknp6XJEkB3sfqB4b3Sz0STEQtoLStQjDt6MN98R8MP332PpGNiHk9tdiCRP9bAkL5JeoMojX9tU8tJRQ==:
ssh_auth:
– present
– user: cedwards
– enc: ssh-rsa

The important bit is to paste in the public key followed by a colon (“:”). Instructions on creating an SSH private and public key pair: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

Make sure you have created the user by putting this in the same file (or anywhere else if you prefer):

backupuser:
user.present:
– password:

See this for info on getting the password hash for a user account. The above salt state doesn’t use the literal password. Rather, you paste in the password hash for that account. http://www.slashroot.in/how-are-passwords-stored-linux-understanding-hashing-shadow-utils

I based this post off info I got here:
http://intothesaltmine.org/blog/html/2012/12/08/managing_authorized_keys_with_salt.html