vagrant-managed-servers icon indicating copy to clipboard operation
vagrant-managed-servers copied to clipboard

Override SSH port

Open snolahc opened this issue 10 years ago • 3 comments

Hi,

First thanks for your really useful provider !

i need specific SSH ports to access my servers and the option is not available in the Vagrantfile, the 22 port is hard-coded in the plugin.

Line 24 of provider.rb : :port => @machine.provider_config.ssh-port

maybe ? the 22 port is hard-coded in action/read_state.rb but seems unused.

thanks :)

snolahc avatar Sep 23 '15 08:09 snolahc

Indeed this is currently unused: https://github.com/tknerr/vagrant-managed-servers/blob/master/lib/vagrant-managed-servers/action/read_state.rb#L56

However this one is relevant : https://github.com/tknerr/vagrant-managed-servers/blob/master/lib/vagrant-managed-servers/provider.rb#L24

We might be able to reuse the builtin config.vm.ssh_port option here (see https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html) instead of hardcoding to 22.

So much I can tell now, but I can't do much further because other things are currently using up my time...

PR are welcome

tknerr avatar Sep 23 '15 14:09 tknerr

I needed to run over a ssh tunnel opened on port 9022.

I was going to debug this, but the plugin actually works properly when overriding the ssh port as seen below:

  config.vm.define "thirdbox" do |thirdbox| 

    thirdbox.vm.box = "tknerr/managed-server-dummy"
    thirdbox.vm.provider :managed do |managed, override|
      managed.server = "127.0.0.1"
      override.ssh.username = "niko"
      override.ssh.port = 9022
      override.ssh.private_key_path = "~/.ssh/id_rsa"
    end

  end

hellonico avatar Jan 22 '16 05:01 hellonico

@snolahc does the approach shown by @hellonico work for you?

If not, can you provide a Vagrantfile example where it does not work?

tknerr avatar Sep 14 '16 23:09 tknerr