Vagrant - how do I get provision code to run before config.ssh.username = 'root'? -


i trying default vm in vagrant environment log in root user. code outside of control must run root , can't run using sudo (files copied /root, etc.). problem having vagrant seems try log in root before provision code run (which copies public key /root/.ssh/authorized_keys file).

i have line in vagrantfile:

config.ssh.username = 'root' 

when run vagrant (clean env, vm freshly downloaded) end this:

centos64: ssh username: root centos64: ssh auth method: private key centos64: warning: connection timeout. retrying... centos64: warning: authentication failure. retrying... centos64: warning: authentication failure. retrying... 

if ctrl-c out of (or let time out), clear provision code:

config.vm.provision "shell" |s|     s.path = 'provision.sh'   end 

which this:

mkdir /root/.ssh touch /root/.ssh/authorized_keys cat /home/vagrant/.ssh/authorized_keys >> /root/.ssh/authorized_keys 

has not been run.

but, if comment out line:

#config.ssh.username = 'root' 

then, run vagrant (again, clean install vm downloaded scratch), starts. uncomment line, , run vagrant second time, , can ssh in root, , can see provision code has indeed been run(from first vagrant up) , key in authorized_keys file.

so, question this: how provision code run before config setting tells use root log in?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -