dustymabe/vagrant-sshfs

does not work behind http proxy

furlongm opened this issue · 2 comments

If the sshfs client is not installed, the guest fails to come up when a proxy is required:

==> network: Installing SSHFS client...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

apt-get update

Stdout from the command:

Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
  Could not connect to archive.ubuntu.com:80 (91.189.91.26). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::19). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1560:8001::11). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1560:8001::14). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::21). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.24). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.149). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.91.23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.31). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.162). - connect (101: Network is unreachable)
Ign:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Ign:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Err:4 http://archive.ubuntu.com/ubuntu bionic-updates Release
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::19). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1560:8001::11). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1560:8001::14). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::21). - connect (101: Network is unreachable)
Err:5 http://archive.ubuntu.com/ubuntu bionic-backports Release
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::19). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1560:8001::11). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1560:8001::14). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::21). - connect (101: Network is unreachable)
Err:6 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1560:8001::14). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::19). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1560:8001::11). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::21). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.162). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.26). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.23). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.24). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.149). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.31). - connect (101: Network is unreachable)
Reading package lists...


Stderr from the command:

E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates Release' no longer has a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-backports Release' no longer has a Release file.

It would be nice to have options for http_proxy and https_proxy that apt/yum etc could use.

Hello @furlongm,

I'd be curious if you could share an example Vagrantfile? For what it's worth I am one of the maintainers of another vagrant plugin called vagrant-proxyconf and I am thinking I could help you get your Vagrantfile setup so that you can use vagrant-sshfs behind a proxy and allow vagrant-proxyconf to configure your proxies before vagrant-sshfs tries to install. I use vagrant-sshfs daily and I know it works very well with vagrant-proxyconf as I normally run my integration tests with vagrant-sshfs.

I'll provide an example Vagrantfile when I am back from appts this morning.

As promised. Here's an example how to use vagrant-sshfs and vagrant-proxyconf at the same time.

how to install vagrant-proxyconf

vagrant plugin install vagrant-proxyconf

how to update vagrant-proxyconf

vagrant plugin update vagrant-proxyconf

Example vagrantfile that uses vagrant-sshfs and vagrant-proxyconf

$PROXY_HOST ="1.2.3.4"
$PROXY_PORT="8888"
$PROXY_NO_PROXY=[
  'localhost',
]

ENV['HTTP_PROXY']  = ENV.fetch('HTTP_PROXY',  "http://#{$PROXY_HOST}:#{$PROXY_PORT}")
ENV['HTTPS_PROXY'] = ENV.fetch('HTTPS_PROXY', "http://#{$PROXY_HOST}:#{$PROXY_PORT}")
ENV['NO_PROXY']    = ENV.fetch('NO_PROXY',    $PROXY_NO_PROXY.join(","))

puts "HTTP_PROXY  = '#{ENV["HTTP_PROXY"]}'"
puts "HTTPS_PROXY = '#{ENV["HTTPS_PROXY"]}'"
puts "NO_PROXY    = '#{ENV["NO_PROXY"]}'"

puts "is vagrant-proxyconf installed? #{Vagrant.has_plugin?('vagrant-proxyconf')}"

Vagrant.configure("2") do |config|
  config.vm.define 'docker_host' do |c|
    c.vm.box = "centos/7"
    c.vm.box_check_update = false

    if Vagrant.has_plugin?('vagrant-proxyconf')
      c.proxy.http     = ENV['HTTP_PROXY']
      c.proxy.https    = ENV['HTTPS_PROXY']
      c.proxy.no_proxy = ENV['NO_PROXY']
    end

    if Vagrant.has_plugin?('vagrant-vbguest')
      c.vbguest.auto_update = false
      c.vbguest.auto_reboot = true
    end

    # place your provision scripts here and before your synced_folder to ensure that vagrant-proxyconf
    # has a chance to configure yum before installing and setting up sshfs.

    c.vm.synced_folder ".", "/vagrant",
      disabled: false,
      type: "sshfs",
      ssh_opts_append: "-o Compression=yes -o ControlPersist=60s -o ControlMaster=auto",
      sshfs_opts_append: "-o cache=no -o nonempty"

  end
end