Ssh – Bootstrapping servers with chef, and changing the SSH Port

chefssh

I have a full set of recipes that are working to bootstrap a server at Rackspace, it configures and installs everything as needed. Now, I want to change the default port SSH runs on. This is fairly easy to do, but the question is, how do I tell Knife to use 22 when bootstrapping, but the non standard port when doing everything else on registered nodes?

Best Answer

This has been in chef since version 0.9.16. You can configure the port by adding the following to your .chef/knife.rb.

knife[:ssh_port] = '22'

Change 22 to the port you want. You don't need to pass -c to the knife bootstrap command if your configuration is in .chef/knife.rb in the current directory.

Ticket for this feature.

Commit for the change.

More information on configuring knife can be found on the Chef wiki:

Related Topic