With puppet it's fairly easy to login from HostA to remote HostB when using SSH.
First create a SSH public/private key pair on HostA like so:
$ sshkeygen -t rsa -f name-of-your-key
Now connect to the remote HostB and create a .ssh folder in the home-folder (if it not already exists):
$ mkdir -p ~/.ssh
Now, from local HostA run this command to append your public key to authorized_keys on the remote HostB:
$ cat .ssh/name-of-your-key.pub | ssh b-user@HostB 'cat >> .ssh/authorized_keys'
Also create locally this file in ~/.ssh/config:
Now you can login like so:
$ ssh HostB
What's the puppet manifest for this?
# contents of ssh_userb.pp
ensure => 'present',
key => 'verylongkey-sdisjklshfjdklsfjssjklASJDLDkj$'
type => 'rsa',
user => 'user-b',
Where the value of key is the value found in name-of-your-key.pub without the "ssh-rsa" prefix and the name suffix.
You can now apply this puppet manifest like so on the remote HostB:
$ puppet apply /path/to/ssh_userb.pp