hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.29k stars 4.43k forks source link

SSH forwarding broken during provisioning step (Windows) #12776

Open cskwrd opened 2 years ago

cskwrd commented 2 years ago

Vagrant version

Vagrant 2.2.19

Host operating system

Windows 10 - VirtualBox 6.1.34

Guest operating system

I tried: hashicorp/bionic64 and bento/debian-10

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/bionic64"

  config.ssh.forward_agent = true

  config.vm.provision "shell", inline: "ssh -Tv git@github.com -o StrictHostKeyChecking=no"
end

NOTE: A valid GitHub public key is needed in the host ssh agent.

Expected behavior

A message indicating a successful connection to GitHub SSH servers.

Actual behavior

Permission is denied.

Steps to reproduce

  1. vagrant up
  2. Observe failure
  3. vagrant ssh -c "ssh -Tv git@github.com -o StrictHostKeyChecking=no"
  4. Observe success

References

Are there any other GitHub issues (open or closed) that should be linked here? For example:

cskwrd commented 2 years ago

I dug around a little more and found GH-8615, and it seems to mention the same problem. I have tested, and when running pageant.exe agent forwarding works while the provisioner is running.

Can the fact that provisioner requires pageant.exe for agent forwarding be added to the docs?

countzero commented 2 years ago

@cskwrd: I can reproduce that SSH agent forwarding in a provisioning context does not work on Windows. See https://github.com/hashicorp/vagrant/issues/12062#issuecomment-1279788972 for a minimal test case.

But I would classify this behavior as a bug and not a lack of documentation: The official OpenSSH package works correctly on Windows. The problem is the shell provisioning implementation of Vagrant, that seems to use another mechanism than the properly functioning vagrant ssh command.

As a cross-platform SSH user, I am not willing to rely on the third party SSH authentication agent pageant (https://en.wikipedia.org/wiki/PuTTY).