I have vagrant vm centos 7 running ssh on XXXX port (not default 22)
How can I connect to XXXX port using "vagrant ssh" command
I tried this but did not work.
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh" , disabled: true
config.vm.network :forwarded_port, guest: xxxx, host: 2223, auto_correct: true
config.ssh.port = 2223
It might depend on the provider you're using, but setting config.ssh.guest_port=XXXX
along with a port forwarding does the trick for me when using Virtualbox as a provider.
With that you shouldn't even have to specify config.ssh.port
, as Vagrant will detect the port forwarding settings automatically.
See also vagrantfile documentation