Use Chef Knife with SDM
When using the
knife ssh command, Knife reaches out to the Chef server with a query string, Chef responds back with a list of hosts that match that query string, and Knife then runs commands via SSH on all returned hosts. This document describes how to set up strongDM SSH functionality to work with the
knife ssh command.
This guide assumes all relevant servers have already been configured to work with Chef and are using an SSH client that supports the Include directive (OpenSSH 7.3+).
Configure all Chef-configured SSH hosts in strongDM under the Servers page. Grant appropriate role-based access to these servers to the strongDM users that will be using Knife.
At the command line of a system running the strongDM client, run
$ sdm ssh config. This will do two things:
Generate an SSH config file in
$HOME/.sdm/ssh_configcontaining entries for each SSH server the user has rights to
Add a line to the top of
$HOME/.ssh/configto reference the generated file
sdm ssh configcommand will generate an
ssh_configfile based on how the SSH server is configured within strongDM. Keep in mind that Knife resolves IP addresses on the client side, so in order for strongDM to properly intercept those SSH calls, it must be aware of the hostname of the SSH server as seen by the Knife client. In practice, this means setting up the SSH servers in the strongDM UI with the hostname that Knife resolves and uses.
Connect to the servers you want to access using
sdm: either click on each one in the UI and ensure the green lightning bolt icon is visible next to each, or run
sdm connect sdm_server_namefor each (or optionally,
sdm connect --all).
To test, run a Knife command that will reference one specific host that is now in your custom
ssh_config. If you have not explicitly connected to that host, you should get a
Not connected via
$ sdm statusSSH SERVER STATUS PORT TYPEchefnode1 not connected 61927 ssh$ knife ssh 'name:node1-ubuntu' 'echo hello'WARNING: Failed to connect to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com -- Errno::ECONNREFUSED: Connection refused - connect(2) for [::1]:61927
$ sdm connect chefnode1connect successful$ sdm statusSSH SERVER STATUS PORT TYPEchefnode1 connected 61927 ssh$ knife ssh 'name:node1-ubuntu' 'echo hello'ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com hello