vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

An error occurred executing a remote WinRM command.

Open hihijskim opened this issue 2 years ago • 7 comments

Vagrant version

Vagrant 2.2.19 (2.2.19+dfsg-1ubuntu1)

Host operating system

Ubuntu 22.04 LTS \n \l

Guest operating system

Windows 10 x64

Vagrantfile

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

# Define guest here (e.g.)
guests = [
  {
    :name => "win10_1",
    :ip => "192.168.56.110"

  }
]

Vagrant.configure("2") do |config|
  guests.each do |opts|
    config.vm.define opts[:name] do |guestconfig|
      guestconfig.vm.box = "win10x64-220117"

      guestconfig.vm.communicator = "winrm"

      guestconfig.vm.network "private_network", ip: opts[:ip]
      guestconfig.ssh.private_key_path = ".ssh/id_rsa"

      guestconfig.vm.synced_folder ".", "/host"

      guestconfig.vm.provider "virtualbox" do |vb|
        vb.cpus = 8 
        vb.memory = "8192"
      end
    end
  end

  config.vm.provision "shell", path: ".ssh/config_sshd.ps1"

end

Debug output

DEBUG virtualbox_6_1:   - [1, "ssh", 2222, 22, "127.0.0.1"]                                                                                                                               
DEBUG virtualbox_6_1:   - [1, "winrm", 55985, 5985, "127.0.0.1"]                                                                                                                          
DEBUG virtualbox_6_1:   - [1, "winrm-ssl", 55986, 5986, "127.0.0.1"]                                                                                                                      
DEBUG winrmshell: initializing WinRMShell                                                                                                                                                 
 INFO winrmshell: Attempting to connect to WinRM...                                                                                                                                       
 INFO winrmshell:   - Host: 127.0.0.1                                                                                                                                                     
 INFO winrmshell:   - Port: 55985                                                                                                                                                         
 INFO winrmshell:   - Username: vagrant                                                                                                                                                   
 INFO winrmshell:   - Transport: negotiate                                                                                                                                                
DEBUG winrmshell: [WinRM] opening remote shell on http://127.0.0.1:55985/wsman                                                                                                            
ERROR warden: Error occurred: An error occurred executing a remote WinRM command.         
...

Shell: Cmd                                                                                                                                                                                                                                                                 
Command: hostname                                                                                                                                                                                                                                                          
Message: Digest initialization failed: initialization error                                                                                                                                                                                                                
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
ERROR warden: Error occurred: An error occurred executing a remote WinRM command.                                                                                                                                                                                          
                                                                                                                                                                                                                                                                           
Shell: Cmd                                                                                                                                                                                                                                                                 
Command: hostname                                                                                                                                                                                                                                                          
Message: Digest initialization failed: initialization error                                                                                                                                                                                                                
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
ERROR warden: Error occurred: An error occurred executing a remote WinRM command.                                                                                                                                                                                          
                                                                                                                                                                                                                                                                           
Shell: Cmd                                                                                                                                                                                                                                                                 
Command: hostname                                                                                                                                                                                                                                                          
Message: Digest initialization failed: initialization error                                                                                                                                                                                                                
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
ERROR warden: Error occurred: An error occurred executing a remote WinRM command.                                                                                                                                                                                          
                                                                                                                                                                                                                                                                           
Shell: Cmd                                                                                                                                                                                                                                                                 
Command: hostname                                                                                                                                                                                                                                                          
Message: Digest initialization failed: initialization error                                                                                                                                                                                                                
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
 INFO warden: Beginning recovery process...                                                                                                                                                                                                                                
 INFO warden: Recovery complete.                                                                                                                                                                                                                                           
 INFO environment: Released process lock: machine-action-f40cac0d631618a536c3e3a480ef5ec5                                                                                                                      
 INFO environment: Running hook: environment_unload                                              
 INFO runner: Running action: environment_unload #<Vagrant::Action::Builder:0x00007fc48495a970>                                                                                                                
ERROR vagrant: Vagrant experienced an error! Details:                                                                                                                                                          
ERROR vagrant: #<VagrantPlugins::CommunicatorWinRM::Errors::ExecutionError: An error occurred executing a remote WinRM command.                                                                                
                                                                                                       
Shell: Cmd                                                                                                                                                                                                     
Command: hostname                                                                                      
Message: Digest initialization failed: initialization error>                                                                                                                                                   
ERROR vagrant: An error occurred executing a remote WinRM command.

Shell: Cmd                                                                                                                                                                                
Command: hostname                                                                                                                                                                         
Message: Digest initialization failed: initialization error                                                                                                                               
ERROR vagrant: /usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:198:in `raise_winrm_exception'                                                
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:140:in `rescue in execute_with_rescue'                                                       
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:137:in `execute_with_rescue'                                                                 
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:71:in `block in cmd'                                                                         
/home/host/.vagrant.d/gems/3.0.2/gems/winrm-2.3.6/lib/winrm/connection.rb:42:in `shell'                                                                                                   
...
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:246:in `action_raw'                                                                                                                                                                         
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:215:in `block in action'                                                                                                                                                                    
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/environment.rb:614:in `lock'                                                                                                                                                                           
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:201:in `call'                                                                                                                                                                               
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:201:in `action'                                                                                                                                                                             
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'                                                                                                                                                        
/home/host/.vagrant.d/gems/3.0.2/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'                                                                                                                                        
 INFO interface: error: An error occurred executing a remote WinRM command.                                                                                                                                                                                                
                                                                                                                                                                                                                                                                           
Shell: Cmd                                                                                                                                                                                                                                                                 
Command: hostname                                                                                                                                                                                                                                                          
Message: Digest initialization failed: initialization error                                                                                                                                                                                                                
An error occurred executing a remote WinRM command.                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                           
Shell: Cmd                                                                                                                                                                                                                                                                 
Command: hostname                                                                                                                                                                                                                                                          
Message: Digest initialization failed: initialization error                                                                                                                                                                                                                
 INFO interface: Machine: error-exit ["VagrantPlugins::CommunicatorWinRM::Errors::ExecutionError", "An error occurred executing a remote WinRM command.\n\nShell: Cmd\nCommand: hostname\nMessage: Digest initialization failed: initialization error"]  

Expected behavior

Vagrant should communicate with the guest through winrm. Or should show more detail info to recover.

Actual behavior

Fails to Initialize and Information is useless

Steps to reproduce

  1. Vagrant up --debug

References

hihijskim avatar Jul 01 '22 05:07 hihijskim

Some says this is ruby related issue: https://bugs.ruby-lang.org/issues/6137 So, my ruby version: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

hihijskim avatar Jul 01 '22 05:07 hihijskim

I faced the same issue some time ago. Downgrading to 2.2.18 fixed it. I reached this issue now because once again, I struggled on a new system until I remembered that using the latest version is not working fine for windows VMs. I'm using Ubuntu 22.04 as a host.

mahmoud-ashi avatar Jul 01 '22 17:07 mahmoud-ashi

Hi there,

Please install Vagrant using the official package. If you still encounter the error after updating your installation, let me know and I will investigate further.

Thanks

chrisroberts avatar Jul 12 '22 15:07 chrisroberts

Hi,

I'm using the official package (on an Ubuntu 22.04 install) and I'm getting the same problem:

ERROR vagrant: Vagrant experienced an error! Details:
ERROR vagrant: #<VagrantPlugins::CommunicatorWinRM::Errors::ExecutionError: An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Digest initialization failed: initialization error>
ERROR vagrant: An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Digest initialization failed: initialization error
ERROR vagrant: /usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:198:in `raise_winrm_exception'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:140:in `rescue in execute_with_rescue'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:137:in `execute_with_rescue'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:71:in `block in cmd'
/home/jbiason/.vagrant.d/gems/3.0.2/gems/winrm-2.3.6/lib/winrm/connection.rb:42:in `shell'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/shell.rb:70:in `cmd'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/communicator.rb:107:in `block in ready?'
/usr/lib/ruby/3.0.0/timeout.rb:97:in `block in timeout'
/usr/lib/ruby/3.0.0/timeout.rb:35:in `block in catch'
/usr/lib/ruby/3.0.0/timeout.rb:35:in `catch'
/usr/lib/ruby/3.0.0/timeout.rb:35:in `catch'
/usr/lib/ruby/3.0.0/timeout.rb:112:in `timeout'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/winrm/communicator.rb:106:in `ready?'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:281:in `guest'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/provisioners/shell/provisioner.rb:209:in `provision_winrm'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/provisioners/shell/provisioner.rb:32:in `provision'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/plugin/v2/trigger.rb:324:in `run_remote'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/plugin/v2/trigger.rb:208:in `block in execute'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/plugin/v2/trigger.rb:181:in `each'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/plugin/v2/trigger.rb:181:in `execute'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/plugin/v2/trigger.rb:58:in `fire'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/builtin/trigger.rb:30:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/builtin/delayed.rb:21:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:246:in `action_raw'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:215:in `block in action'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/environment.rb:614:in `lock'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:201:in `call'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/machine.rb:201:in `action'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.19/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
/home/jbiason/.vagrant.d/gems/3.0.2/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
 INFO interface: error: An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Digest initialization failed: initialization error
An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Digest initialization failed: initialization error
 INFO interface: Machine: error-exit ["VagrantPlugins::CommunicatorWinRM::Errors::ExecutionError", "An error occurred executing a remote WinRM command.\n\nShell: Cmd\nCommand: hostname\nMessage: Digest initialization failed: initialization error"]

If I run nc -v 127.0.0.1 55985, it connects without any issues.

Let me know if you need any other information.

jbiason avatar Jul 13 '22 14:07 jbiason

@jbiason Hi, thanks for the information. The installation of vagrant you are using is not the official build. The official build can be found here. Do you still encounter the same error using the official build?

chrisroberts avatar Jul 13 '22 16:07 chrisroberts

Actually, my install followed all the steps from the linked page. If there is another version, then the install instructions are wrong.

Edit: Yup, install instructions are wrong. It assumes the Vagrant from Hashicorp repo is in a higher version than the Canonical one, but because Canonical is using the same version (2.2.19) plus some indication about Ubuntu themselves (2.2.19+dfsg-1ubuntu1). The only way to actually get the Hashicorp version is using apt install vagrant=2.2.19.

That fixes the issue, though.

jbiason avatar Jul 13 '22 16:07 jbiason

I've run into a similar issue which also was resolved by explicitly choosing a version of vagrant that is provided by Hashicorp's PPA rather than Canonical's:

==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:55985
    default: WinRM username: vagrant
    default: WinRM execution_time_limit: PT2H
    default: WinRM transport: negotiate
An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Digest initialization failed: initialization error

A more permanent solution (that's going to survive through apt upgrade/dist-upgrade/full-upgrade would be to create a preference file, e.g. /etc/apt/preference.s/hashicorp:

Package: *
Pin: origin apt.releases.hashicorp.com
Pin-Priority: 999

Jackenmen avatar Jul 17 '22 04:07 Jackenmen

Repository has been updated to account for this and the proper package installs now when following instructions on site so closing this up. Cheers!

chrisroberts avatar Aug 29 '22 18:08 chrisroberts

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Sep 29 '22 02:09 github-actions[bot]