0

I am trying to SSH into a specific vagrant box from the command line:

vagrant ssh winbox password

'winbox' is what the box appears to be called in 'vagrant box list'. However, upon the entry of that command I get:

The machine with the name 'winbox' was not found configured for
this Vagrant environment.

If I just do 'vagrant ssh' It all works fine so I'm pretty sure I'm getting the box name wrong. The same box name appears in the vagrant file for the box:

Vagrant.configure("2") do |config|
config.vm.box = "winbox"
config.ssh.username = "vagrant"
config.ssh.password = ******
config.vm.network :forwarded_port, guest: 4444, host: 4440
config.vm.network :forwarded_port, guest: 5555, host: 5555
end

Is there any way to check the name of the currently running vagrant box?

It is important that I log into the box all in one line because I am basically using Java to execute command line code from within a JUNIT test and it's not possible to first go vagrant ssh and then enter a password with it.

Mateusz J
  • 45
  • 7

1 Answers1

0

you only need the box name information when you initiate the new VM.

so either when you run vagrant init winbox or when you change the config.vm.box parameter in your Vagrantfile.

After you have initialized the VM (vagrant up) you can forget about the box, you don't need it anymore (it still needs to be present in your Vagrantfile but you don't reference it anymore)

If you run a single VM in your Vagrantfile, you can just run vagrant ssh to get into the VM.

what you may be confused about the vagrant ssh <VMName> is when you run vagrant multi-machine so in this case a single Vagrantfile will spin multiple VMs and you will need to indicate the name of the VM (not the box) to ssh into the correct VM

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • Hi, as I stated in my post it is important that I log into the box with a single line, as the tool I'm using for interacting with the command line does not really provision for the entry of passwords. So is there any way to enter your password on the same line as you run 'vagrant ssh'? – Mateusz J Aug 23 '16 at 14:53
  • you have the password in your Vagrantfile (parameter `config.ssh.password`) so you don't need to enter it in the command line – Frederic Henri Aug 23 '16 at 15:00
  • I do, vagrant asks me for the password every time. – Mateusz J Aug 24 '16 at 08:49
  • are your sure you need a password ? Vagrant recommends you use key-based authentication rather than a password and most boxes are configured this way - you can use an ssh command directly (check http://stackoverflow.com/questions/10864372/how-to-ssh-to-vagrant-without-actually-running-vagrant-ssh) so you can input your password and verify your connection – Frederic Henri Aug 24 '16 at 09:04