I use Vagrant to create a CentOS VM on Windows host and connect to it, so far so good.
Next I want to use Chef to provision stacks on VM that was created. I tried with local directory cookbooks as well as providing urls to recipes, but that probably fails because it can’t ssh to guest box, as seen from error:
SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.
So my first question is:
1) How do I make sure SSH works within same window that brought up guest OS in Windows Host so that all scripts execute well?
Now when I comment below line in vagrantfile
config.ssh.username = "root"
Above error goes away, but I get another error:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -t vboxsf -o uid=id -u vagrant,gid=id -g vagrant v-csr-2 /tmp/vagrant-chef-1/chef-solo-2/roles
Which is because the user vagrant does not have enough access on box, which is my second question:
2) How do instruct Vagrant to run all commands with sudo or su access?
Here is how I managed to get SSH working:
install cygwin (http://www.cygwin.com/)
setup openssh from within cygwin
add ~/.ssh/id_rsa_vagrant
download from here
modify ~/.ssh/config
Host localhost
IdentityFile ~/.ssh/id_rsa_vagrant
modify rights on ssh directory
chmod 600 ~/.ssh/*
Everything should be working fine.