Reputation: 173
I created keys with command
ssh-keygen -t rsa
chmod 600 .ssh/authorized_keys
Then i used command
ssh-copy-id [email protected]
Now command
ssh 127.0.0.1
doesn't require password.
Then i created hosts file for ansible
[staging_servers]
linux_local ansible_host=127.0.0.1 ansible_connection=ssh ansible_user=timur ansible_ssh_private_key_file=/home/timur/.ssh/authorized_keys
When i run ansible all -m ping
i'm getting error:
[![error picture][1]][1]
What i did wrong? [1]: https://i.sstatic.net/TMKt0.png
Upvotes: 0
Views: 253
Reputation: 7867
If you want just to change something on localhost, there is a better option: use connection: local
in the playbook, or use this inventory:
[staging_servers]
linux_local ansible_connection=local
It will completely skip whole ssh thing and run modules directly on the local machine.
Moreover, from my experience, it's the fastest way to run Ansible. If you can afford to mess with local machine, do it, it's a bliss to work with.
Upvotes: 1