Skip to content

Instantly share code, notes, and snippets.

@fullyint
Last active September 20, 2015 07:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fullyint/1214de193be90278d256 to your computer and use it in GitHub Desktop.
Save fullyint/1214de193be90278d256 to your computer and use it in GitHub Desktop.
# Enable ssh_port option in vagrant-digitalocean
# Diff of /lib/vagrant-digitalocean/actions/create.rb
# wait for ssh to be ready
switch_user = @machine.provider_config.setup?
user = @machine.config.ssh.username
+ port = @machine.config.ssh.port
@machine.config.ssh.username = 'root' if switch_user
+ @machine.config.ssh.port = '22' if port
retryable(:tries => 120, :sleep => 10) do
next if env[:interrupted]
raise 'not ready' if !@machine.communicate.ready?
end
+ @machine.communicate.execute("sed -i 's/Port 22/Port #{port}/' /etc/ssh/sshd_config && service ssh restart") if port
@machine.config.ssh.username = user
+ @machine.config.ssh.port = port if port
@app.call(env)
end
@fullyint
Copy link
Author

fullyint commented Aug 7, 2014

For Ubuntu on Digital Ocean:

This is a diff of the vagrant-digitalocean plugin's create.rb file (as of Aug 7, 2014). It appears that the DO plugin must initiate the DO droplet using ssh port 22. These edits temporarily set the ssh port to 22 for droplet creation, then back to the port specified in the user's Vagrantfile.

Without these changes, if the user has set a non-default port for config.ssh.port in the Vagrantfile, the vagrant up droplet creation hangs forever due to the DO plugin's inability to connect via ssh.

I'd love a more universal solution anyone may share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment