I want to clone a bunch of private git repositories while provisioning a vagrant box. According to this article this should be possible using config.ssh.forward_agent = tr
Please check whether your host system has ssh-agent forwarding enabled. You can do so for example by adding this block to your ~/.ssh/config
file:
Host *
ForwardAgent yes
If this is enabled vagrant ssh
(and also vagrant provision
) should be able to forward your key to the guest machine.
You also might want to check using ssh-add -l
whether your ssh-agent does know about your SSH-key. If it is in the list and you have agent-forwarding activated you should have a success. Otherwise you can add the key to your ssh-agent by running ssh-add <path to your key file>
.
Tom,
What you're doing is fairly generic in nature and I don't think is Vagrant
specific.
Try some of the following to track down the issue:
/etc/ssh/sshd_config
LogLevel debug
sudo service sshd restart
or /etc/init.d/sshd restart
tail -f /var/log/authlog
-- note, the file may be something else like /var/log/authd.log
or /var/log/secure
or something.Again sorry, I'm not that familiar with Vagrant
but I'm wondering if the provisioning script is running as another user, in which case the agent forwarding may not work as expected?
It sounds like you may be hitting this particular bug: https://github.com/mitchellh/vagrant/issues/1735 (Despite it being "closed" it's actually not fixed)
On Windows, SSH Forwarding in Vagrant does not work properly by default (because of a bug in net-ssh).
However, there is a workaround or simple hack. You can auto-copy your local SSH key to the Vagrant VM via a simple provisioning script in your VagrantFile. Here's an example: https://github.com/mitchellh/vagrant/issues/1735#issuecomment-25640783