Performing SSH authentication tasks
Managing SSH keys and the associated files is a key task that needs to be performed in most infrastructure at present to facilitate a number of functions with remote access between servers. Although this task can be achieved by propagating files to the minions using the file module, Salt has a better way to do it using SSH-specific modules. In this recipe, you will learn how to use these modules.
How to do it...
Configure two minions called
salt-minion
andbackup-server
. Configure theserver_type
grain ofsalt-minion
to have the valueapp
and the backup server's value to bebackup
.Create a new state called
sshauth
, and create two files inside this directory calledpubkey.sls
andknown_hosts.sls
. Also create a directory calledsshkeys
inside thesshauth
directory.We will assume that the
groups
andusers
modules, configured in the last recipe, have been applied on both the minions.On the
salt-minion
minion, change to thestg-app
user, and run the following...