2

I have a project and we use Vagrant for our development env. On Mac/Unix the provisioning works perfectly except in Windows, the problem is that forwarding agent doesn't work on windows and therefore, I can't access the private GitHub repos.

I fixed it by adding this in the Vagrantfile:

  # Windows github ssh keys fix
  if Vagrant::Util::Platform.windows?
    # You MUST have a ~/.ssh/github_rsa (GitHub specific) SSH key to copy to VM
    if File.exists?(File.join(Dir.home, ".ssh", "github_rsa"))
      # Read local machine's GitHub SSH Key (~/.ssh/github_rsa)
      github_ssh_key = File.read(File.join(Dir.home, ".ssh", "github_rsa"))
      # Copy it to VM as the /root/.ssh/id_rsa key
      config.vm.provision :shell, :inline => "echo 'Windows-specific: Copying local GitHub SSH Key to VM for provisioning...' && mkdir -p /root/.ssh && echo '#{github_ssh_key}' > /root/.ssh/id_rsa && chmod 600 /root/.ssh/id_rsa"
    else
      # Else, throw a Vagrant Error. Cannot successfully startup on Windows without a GitHub SSH Key!
      raise Vagrant::Errors::VagrantError, "\n\nERROR: GitHub SSH Key not found at ~/.ssh/github_rsa (required on Windows).\nYou can generate this key manually OR by installing GitHub for Windows (http://windows.github.com/)\n\n"
    end
 end

The cloning is done with this Puppet script (which finally works on Windows) when the above script is added to the Vagrantfile:

class install_repos {
  vcsrepo { '/home/vagrant/git_project':
    ensure   => present,
    provider => git,
    source   => '[email protected]:proj_path',
    require => Class['known_hosts']
  }
}

In that same file I have the following in the Gemfile where some gems are pointed to GitHub repos:

exec { 'install_project':
   command     => 'bundle install',
   cwd         => '/vagrant',
   provider    => 'shell',
   require     => [
      Class['install_ruby'],
      Class['known_hosts'],
      Class['install_repos'],
    ]
  }

The bundle install keeps failing if i open SSH to the vagrant instance and i test my Github connection ssh -T [email protected] I get the following:

Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
Permission denied (publickey).

No matter what I try, I can't get it working on Windows and I'm not sure what is actually happening.

5
  • Take a look at the answers to this question, specifically: config.ssh.forward_agent = true. Commented Aug 1, 2014 at 0:35
  • the forward_agent is working on all other OS except Windows i got it fixed will post an answer here Commented Aug 1, 2014 at 10:20
  • @SanderVisser Did you ever find a fix for this? I am having an issue with config.ssh.forward_agent = true as well Commented Aug 18, 2015 at 23:22
  • @ChaseSandmann Not really, but take a look at this: blog.scottlowe.org/2013/10/21/… that should do the trick. at least I would try it Commented Aug 18, 2015 at 23:48
  • Also you can use the vagrantfile piece in the question. But the agent-forwaring is not usable on win =( Commented Aug 18, 2015 at 23:54

0

You must log in to answer this question.

Browse other questions tagged .