I want to have a Vagrant-File that creates a simple VM for Ansible-Testing. For this I need a machine that I can ssh into as root and from everywhere. I want it to have an static IP so I can have unchanged SSH-Host settings and the VM should be in a private Network, obviously it should run python2.7 - So far so good.
I can get everything running EXCEPT dynamically copy my public SSH key into the VMs root authorized\_keys file on creation via the Vagrantfile.
I tried everything I found online but nothing seems to work. This is my latest attempt:
`id_rsa_pub =` [`File.read`](https://File.read)`("~/.ssh/id_rsa.pub") #localtion of your pub key`
`config.vm.provision "shell", inline: <<-SHELL` `sudo -i` `echo "echo "#{id_rsa_pub}" >> /root/.ssh/authorized_keys`
`SHELL`
There must be an obvious way to do such an basic task, right?
there prolly a plugin
Instead of solving this in vagrant you should solve for this in Ansible. use a local unprivileged user and use `become` https://docs.ansible.com/ansible/latest/user_guide/become.html