5

I'm starting vagrant box with Windows 7 from host which is also Windows 7 with "vagrant up" command.

Contents of Vagrantfile:

Vagrant.configure(2) do |config|
  config.vm.box = "win7_base_test"
  config.vm.network "forwarded_port", guest: 88, host: 3088
  config.ssh.username = "vagrant"
  config.ssh.password = "vagrant"
  config.ssh.port = "3088"
  config.ssh.host = "127.0.0.1"
  config.ssh.shell = "cmd"
end

As a result I get following listing with an error at the end:

vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 88 => 3088 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:3088
    default: SSH username: vagrant
    default: SSH auth method: password
    default: Warning: Connection timeout. Retrying...
The configured shell (config.ssh.shell) is invalid and unable
to properly execute commands. The most common cause for this is
using a shell that is unavailable on the system. Please verify
you're using the full path to the shell and that the shell is
executable by the SSH user.

Notice: I'm able to connect to vagrant box by executing "vagrant ssh" in the meantime and issue shell commands there.

Therefore I have a question: do I use the correct value ("cmd") for "config.ssh.shell" parameter? What values are possible there at all?

Thanks!

Viktor Malyi
  • 2,298
  • 2
  • 23
  • 40

4 Answers4

1

One option is to use WinRM instead of SSH: set config.vm.communicator to "winrm".

Emil Styrke
  • 1,073
  • 11
  • 19
0

According to the Vagrant docs, config.ssh.shell only affects what shell is used within Vagrant, not what is used as the shell when you perform vagrant ssh. By default it uses bash, and unless you have a specific need to change this then leave it as that I reckon.

IBam
  • 10,114
  • 1
  • 24
  • 36
0

Use the config.ssh.shell = "powershell" instead of config.ssh.shell = "cmd"

  • Welcome to Stack Overflow! While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Yunnosch Dec 24 '20 at 14:01
0

I had "The configured shell (config.ssh.shell) is invalid..." error after having deleted the vagrant box used for machine creating.

I restored the box and everything worked fine then.

alex_1948511
  • 6,073
  • 2
  • 20
  • 21