tknerr / vagrant-managed-servers

Enables Vagrant to ssh into and provision managed servers
MIT License
185 stars 30 forks source link

Override SSH port #53

Open snolahc opened 8 years ago

snolahc commented 8 years ago

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 :)

tknerr commented 8 years ago

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

hellonico commented 8 years ago

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
tknerr commented 8 years ago

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

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