Getting ssh public key as a variable

Hi,

So i am just trying to know the background on the reason behind having (ansible_ssh_host_key_rsa_public) but not the $HOME/.ssh/id_rsa.pub variable for the user trying to get the facts ?

I don't understand, can you share more about what are you trying to do?

Sorry, I want to understand what is the best practice and what the community uses for the following:

if i have 3 servers, i want to make sure each of the 3 servers can login to each other with their public key. Say user X,

So the logic is simple, basically reading .pub from all 3 nodes and then either use template or use authorized_keys to add all other public key to the authorized file.

Let me know if this sounds stupid,

Regards,–
Kavin Kankeshwar

Ah, interesting.

I would really prefer to see those SSH keys dispensed from the control
node directly, rather than having one node tell another node who can
log into another.

Seems potentially a mess that way.

Thanks for the reply,Sorry i might not have understood your comment,

Trying to clarify: Yes i mean to pull all public keys from nodes to my ansible node and then push out an entire list of SSH authorized keys .

I can easily solve this by sending everyone the same private key and have the same authorized keys :slight_smile: But i am trying to understand how to do some complex stuff with Ansible. :smiley:

Regards,–
Kavin Kankeshwar

It's a little bit of a messy use case.

Such things are doable, but rather than asking to show you, you really
should consider pushing the keys out centrally from an authorative
source.

What you are asking to do is potentially dangerous as if you created a
key on an untrusted box, you're making it automatically have access to
the entire infrastructure.

I don't want to give the example of how to do that :slight_smile:

Ok Thanks :slight_smile: Will push it out.

Regards,–
Kavin Kankeshwar