# SSH authorization in Ansible between local and remote host

**URL:** <https://forum.ansible.com/t/ssh-authorization-in-ansible-between-local-and-remote-host/20619>\
**Category:** Ansible Project\
**Created:** [February 18, 2016, 5:10pm UTC](https://forum.ansible.com/t/ssh-authorization-in-ansible-between-local-and-remote-host/20619 "2016-02-18T17:10:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferenc\_Fabian](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@Ferenc\_Fabian](https://forum.ansible.com/u/Ferenc_Fabian)\
**Post date:** [February 18, 2016, 5:10pm UTC](https://forum.ansible.com/t/ssh-authorization-in-ansible-between-local-and-remote-host/20619/1 "2016-02-18T17:10:35Z")

</div>

```auto
I have a Vagrant box with centos 7 where I am creating LXC containers. An Ansible run in the Vagrant box. I create the container with Ansible like this: 

 - name: Create containers lxc_container: name: localdev_nginx container_log: true template: centos container_config: - 'lxc.network.ipv4 = 192.168.42.110/24' - 'lxc.network.ipv4.gateway = 192.168.42.1' container_command: | yum -y install openssh-server echo "Som*th1ng" | passwd root --stdin ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" state: started

This is create the container for me, but after this I can't access to the container from the Ansible. Just if I take the container ssh pubkey to the Vagrant known_hosts like this: 

    

- name: Tell the host about our servers it might want to ssh to shell: ssh-keyscan -t rsa 192.168.42.110 >> /root/.ssh/known_hosts

And if I add the container root password in the Ansible hosts file like this: 

    

[dev-webservers] loc-dev-www1.internavenue.com hostname=loc-dev-www1.internavenue.com ansible_ssh_host=192.168.42.110 ansible_connection=ssh ansible_user=root ansible_ssh_pass=Som*th1ng 

I hope it has a better solution, because really bad. How can I do it normally? 
  

```
