# ansible ssh connections

**URL:** <https://forum.ansible.com/t/ansible-ssh-connections/35044>\
**Category:** Ansible Project\
**Created:** [April 23, 2021, 3:35pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044 "2021-04-23T15:35:14Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bec12317](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@bec12317](https://forum.ansible.com/u/bec12317)\
**Post date:** [April 23, 2021, 3:35pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/1 "2021-04-23T15:35:14Z")

</div>

Please someone help me. I do not understand why i get this error. I can ssh from my control node to this host and from the host to my control node. But ansible test show this results.

192.168.154.163 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: [control@192.168.154.163](mailto:control@192.168.154.163): Permission denied (publickey,password).”,  
“unreachable”: true

this is my inventory:

192.168.154.163 cyber01\_ssh\_pass=“pass” cyber01\_ssh\_user=user

Thank you

---

<div class="post-metadata">

**Author:** ![Rajit\_Paul](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@Rajit\_Paul](https://forum.ansible.com/u/Rajit_Paul)\
**Post date:** [April 23, 2021, 3:40pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/2 "2021-04-23T15:40:22Z")

</div>

Try ansible\_ssh\_user and ansible\_ssh\_pass as keywords in the inventory and set privilege escalation in the ansible.cfg file also add the user to the sudoers list in managed node as per requirement.

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [April 23, 2021, 3:51pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/3 "2021-04-23T15:51:20Z")

</div>

You can find more from this link - [https://docs.ansible.com/ansible/2.3/intro\_inventory.html#list-of-behavioral-inventory-parameters](https://docs.ansible.com/ansible/2.3/intro_inventory.html#list-of-behavioral-inventory-parameters)

---

<div class="post-metadata">

**Author:** ![bec12317](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@bec12317](https://forum.ansible.com/u/bec12317)\
**Post date:** [April 23, 2021, 4:23pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/4 "2021-04-23T16:23:36Z")

</div>

Thank you. Trying the options. I have sat on it the whole day, i feel exhausted with it.  
Thank you. I will get back whatever results i have

---

<div class="post-metadata">

**Author:** ![NAVEEN](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@NAVEEN](https://forum.ansible.com/u/NAVEEN)\
**Post date:** [April 26, 2021, 9:24am UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/5 "2021-04-26T09:24:44Z")

</div>

Hello Team ,  
I have oen requirement on Ansible with Hp ILO server…

I am new to ansible.Need help from you people.  
Requirement is  
Have to connect Hp ilo serverr using SSH and get SWId’s details and the out out i have to display in csv file… can any implementation pls do let me know.  
Naveen

---

<div class="post-metadata">

**Author:** ![Komal\_Suthar](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@Komal\_Suthar](https://forum.ansible.com/u/Komal_Suthar)\
**Post date:** [April 26, 2021, 9:57am UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/6 "2021-04-26T09:57:58Z")

</div>

You can use jinja templates for getting the facts of the server and use template modules for creating your file.

---

<div class="post-metadata">

**Author:** ![NAVEEN](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@NAVEEN](https://forum.ansible.com/u/NAVEEN)\
**Post date:** [April 26, 2021, 10:00am UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/7 "2021-04-26T10:00:44Z")

</div>

do u have any sample code …if u have pls share with me

---

<div class="post-metadata">

**Author:** ![Komal\_Suthar](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@Komal\_Suthar](https://forum.ansible.com/u/Komal_Suthar)\
**Post date:** [April 26, 2021, 10:18am UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/8 "2021-04-26T10:18:32Z")

</div>

template:  
src : file.txt

Inside this file.txt…  
The default IPv4 address of {{ ansible\_facts.fqdn }}  
is {{ ansible\_facts.default\_ipv4.address }}

dest : file.csv

Some facts example there are lots of facts related to that server you have to fetch or serch in docs

---

<div class="post-metadata">

**Author:** ![Mauricio\_Tavares](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mauricio\_Tavares](https://forum.ansible.com/u/Mauricio_Tavares)\
**Post date:** [April 26, 2021, 11:10am UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/9 "2021-04-26T11:10:57Z")

</div>

How about if you start your own thread instead of breaking into  
someone else's? Your question has nothing to do with the OP's

---

<div class="post-metadata">

**Author:** ![Mauricio\_Tavares](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mauricio\_Tavares](https://forum.ansible.com/u/Mauricio_Tavares)\
**Post date:** [April 26, 2021, 11:30am UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/10 "2021-04-26T11:30:21Z")

</div>

> Thank you. Trying the options. I have sat on it the whole day, i feel exhausted with it.  
> Thank you. I will get back whatever results i have

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Some suggestions, assuming the name of the host you want to run  
ansible on is 'cyber01' and going from simpler to more sophisticated:

1. Test by passing the username and asking for the password from the  
command line. In this example I am just running the 'whoami' command:

ansible cyber01 --extra-vars 'ansible\_user=user' --ask-pass -a whoami

2. Do not have passwords defined in your inventory. If you need a  
password, ask for them as shown above.

3. Instead of password, consider a SSH keypair. This way you can have  
something like this in your inventory

192.168.154.163 ansible\_ssh\_private\_key\_file="~/.ssh/cyber01" ansible\_user=user

Note it is looking for the private key at my user's default location;  
where you place it depends on your needs.

4. Consider having a host\_vars/cyber01.yml file instead of cluttering  
the inventory one. You can then populate this file with all the  
initial constants you need (IP address, username, etc), passing any  
variables that might change at runtime using --extra\_vars as shown  
above.

---

<div class="post-metadata">

**Author:** ![NAVEEN](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@NAVEEN](https://forum.ansible.com/u/NAVEEN)\
**Post date:** [April 26, 2021, 2:28pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/11 "2021-04-26T14:28:08Z")

</div>

Hi  
Anyone available for job support on ansible …if any pls email me on [naveenkraju@gmail.com](mailto:naveenkraju@gmail.com)

Thank you  
Naveen

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [April 26, 2021, 2:47pm UTC](https://forum.ansible.com/t/ansible-ssh-connections/35044/12 "2021-04-26T14:47:14Z")

</div>

Please do not hijack conversation threads for new topics - start a new thread  
with an appropriate subject of its own.

Thank you,

Antony.
