1

I wrote a chef cookbook and it runs fine with test-kitchen. Now I want to harden ssh access to the production nodes by writing a recipe that overwrites /etc/ssh/sshd_config. Among other things, it changes the ssh port to a non-default one.

When now running "kitchen login" after "kitchen converge", it fails, because it can't connect on the default port.

Is there a way to configure test-kitchen with a different ssh port? Or is there a different way to do this? Could I recognize whether the recipe is running in test-kitchen and only change the ssh port in production environments?

1 Answer 1

2

I found a solution. Kitchen can override node attributes in the .kitchen.yml file. So using an attribute for the ssh port does the trick.

2
  • I still get SSH session could not be established] on default-debian-9 >>>>>> Failed to complete #verify action: [Transport error, can't connect to 'ssh' backend: SSH session could not be established] on default-centos-7 >>>>>> ---------------------- >>>>>> Please see .kitchen/logs/kitchen.log for more details >>>>>> Also try running ``kitchen diagnose --all`` for configuration... Dec 17, 2018 at 19:35
  • Never mind, I see what you are saying. Set the attribute to 22 in the kitchen-test run, you can change it when running in production. Dec 17, 2018 at 19:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .