Goal
For testing, we want this to work: ssh $USER@localhost
.
- create rsa keypair in ~/.ssh/, if not already there
- add .ssh/id_rsa.pub to .ssh/authorized_keys, if not already in this file.
Question
How to do this with salt-stack?
State:
generate_ssh_key_my_user:
cmd.run:
- name: ssh-keygen -q -N '' -f /home/my_user/.ssh/id_rsa
- runas: my_user
- unless: test -f /home/my_user/.ssh/id_rsa
State for authorized_key:
ssh_auth.present:
- user: my_user
- require:
- user: my_user
- names:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGt6eIzilRygebgpzpRwVgja7NbXrGHgG7QbIxOhSUpwmuzJ7nHELrbbA9z+CyTFZwRtpr27OQDv7L8ox5Wp6iCFxyb5Y8sVC8vyYNoFPTfMz4qtgf0xXZRDAzzkeczuMqQubnJtanxhR7t9H2RBSxLvZkqD18O/GekCXBmR43yrBi03rVHcvumTW6m5Kg5qihq/adhVQDutiCp3ICq/blahbasd my_user@
that ssh-rsa is your generated .pub key