vagrant ssh boxname doesn't work

Created on 15 Jun 2017  Â·  6Comments  Â·  Source: hashicorp/vagrant

Vagrant version

Vagrant 1.9.5

Host operating system

Ubuntu 16.04 LTS

Expected behavior

ssh into the box

Actual behavior

A Vagrant environment or target machine is required to run this
command. Run `vagrant init` to create a new Vagrant environment. Or,
get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

Steps to reproduce

  1. vagrant ssh boxname # bind9, the name listed in vagrant global-status
  2. vagrant ssh boxid # 6911eda, the id listed in vagrant global-status

1 gets the "actual behavior", #2 works as expected.

communicatossh core

Most helpful comment

Ok, please update the documentation, it is easy to mislead people.
Still, I still feel that using a name to ssh globally is a good idea , should not be limited to local project machines。

All 6 comments

Hello @paulehoffman !

This sounds like a reasonable idea, however if you have a global state where multiple vagrant machines have identical names, like:

brian@localghost:vagrant-sandbox % be vagrant global-status                                             ±[●●][master]
id       name          provider   state    directory
----------------------------------------------------------------------------------
d47e0a1  ubuntu        virtualbox poweroff /Users/brian/Downloads/vagrant-sandbox
d191d83  default       docker     running  /Users/brian/code/vagrant-sandbox
87c6170  global-puppet virtualbox running  /Users/brian/Downloads/vagrant-sandbox
d0088ab  global-puppet virtualbox running  /Users/brian/code/vagrant-sandbox

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"

Vagrant wouldn't know which machine you intended to ssh into. This would cause some extra work arounds to make sure vagrant uses the correct machine in this scenario. I think in this case, it just makes sense to use the machine id so that vagrant knows exactly which machine the user intends to ssh into.

Thanks for opening the issue!

@briancain +1 to the idea – Docker has this functionality @paulehoffman suggests. As the vagrant command already replies with the message below, would it be substantial overhead to reply with a similar message if 2 machines shared the same name?

A Vagrant environment or target machine is required to run this
command. Run `vagrant init` to create a new Vagrant environment. Or,
get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

@briancain I use a unique box name(vagrant ssh lnmp), but not into box。So, I think that a unique box name is not the problew
my box list below:

id       name    provider   state    directory
-------------------------------------------------------------------------
f469dc4  default virtualbox poweroff /Users/luo/Vagrant/ubuntu
253e5c3  lnmp    virtualbox running  /Users/luo/Vagrant/centos69_lnmp

As Offical Document describe: vagrant ssh [name|id] which can ssh into box, so the command should take affect when using a unique boxname in theory. I don't know why the actual operation is inconsistent with the document description.

@paulehoffman Have you found the reason?

@MwumLi we will review the documentation and update, however.

local project machines can be accessed by name, they came from the output of:

vagrant status

can be default, or multiples names in a multi-machine setup.

The machines outside the local repo, like the output of

vagrant global-status

need the id of the machine.

Thanks
Alvaro.

Ok, please update the documentation, it is easy to mislead people.
Still, I still feel that using a name to ssh globally is a good idea , should not be limited to local project machines。

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janw-me picture janw-me  Â·  3Comments

OtezVikentiy picture OtezVikentiy  Â·  3Comments

barkingfoodog picture barkingfoodog  Â·  3Comments

RobertSwirsky picture RobertSwirsky  Â·  3Comments

DreadPirateShawn picture DreadPirateShawn  Â·  3Comments