Hello.
There are two hosts. On first I create a user and generate SSH keys. Now I need to transfer private key to second host to connect using it to first host without creating a user on second. I haven’t found an output of parameter ssh_key as analogg to ssh_public_key in module user. In other modules related to SSH there is only a possibility to see contents of public key. What is the reason for this restriction?
The documentation is written about the path to the ssh public key. in the example of a private key.
ssh_key_file Path to generated SSH public key file. Sample: /home/asmith/.ssh/id_rsa
On 22.03.19 07:51, Alexander B. wrote:> Hello.
There are two hosts. On first I create a user and generate SSH keys.
Now I
need to transfer private key to second host to connect using it to first
host without creating a user on second. I haven't found an output of
parameter ssh_key as analogg to ssh_public_key in module user. In other
modules related to SSH there is only a possibility to see contents of
public key. What is the reason for this restriction?
Because the private key should be _private_ and not be transferred
around the network.
If you need to be able to login from host2 to host1, you need to
generate a ssh keypair on host2, (either using the user module or
command module), fetch the contents of the public key, and use the
authorized_key module to put the public key into the authorized_keys
file for the user.
The documentation
<https://docs.ansible.com/ansible/latest/modules/user_module.html> is
written about the path to the ssh public key. in the example of a private
key.
ssh_key_file Path to generated SSH public key file. *Sample*:
/home/asmith/.ssh/id_rsa
That one is a bug in the docs, it's fixed in the devel docs:
https://docs.ansible.com/ansible/devel/modules/user_module.html
- Sebastian