-1

I have a Vagrant file looks like the one below.

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.ssh.host = "0.0.0.0"
  config.ssh.password = "foo"
end

I want to access to my box via an SSH tool. When I try to connect it with a command like ssh vagrant@0.0.0.0:22, I encounter with an error that says ssh: Could not resolve hostname 0.0.0.0:22: nodename nor servname provided, or not known .

According to Vagrant documents, it is possible to set a hostname and password by setting host and password properties of ssh object of the config.

I am sure that the current Vagrant box is up and running. I can even access apache via port 80 if I set forwarded_port attribute.

config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "127.0.0.1"

amone
  • 3,712
  • 10
  • 36
  • 53
  • Did you actually set 0.0.0.0, or is this just a example to not put the real address here ? Because if you did it won't work since 0.0.0.0 is a reserved address, see: https://stackoverflow.com/questions/3655723/is-0-0-0-0-a-valid-ip-address – lee-pai-long Jan 31 '19 at 19:53

1 Answers1

0

That's not valid ssh command line syntax. Use the -p command line parameter to specify the port. For example:

This works: ssh -p 2222 -i /path/to/identity/file vagrant@localhost correct command line syntax

This does not: ssh -i /path/to/identity/file vagrant@localhost:2222 incorrect command line syntax

Note: port 22 is the default port for ssh, if you're attempting to connect to port 22 then you don't have to specify the port.

masseyb
  • 3,745
  • 1
  • 17
  • 29