Open aogail opened 7 years ago
I had the same issue today! I just destroy kitchen and create again.
I have this issue as well. Please can you explain how you monkey patch the connection class? Where do I put the code, and how do I reference it in my .kitchen.yml?
@dfairhurst You put that block of code directly in your .kitchen.yml, inside ERB tags, like this:
<%
# Hack to fix a bug in TK. TK supports using an SSH gateway in its SSH transport, but appears not to support configuring
# separate keys for the gateway and the destination.
require 'kitchen/transport/ssh'
GATEWAY_KEYS = ["#{ENV['HOME']}/.ssh/id_rsa"]
class Kitchen::Transport::Ssh::Connection
# Replace this method in TK core with a version that uses the logged in user's key to access the SSH gateway.
def establish_connection_via_gateway(opts)
retry_connection(opts) do
Net::SSH::Gateway.new(ssh_gateway, ssh_gateway_username, options.merge(keys: GATEWAY_KEYS))
.ssh(hostname, username, options)
end
end
end
%>
driver:
# etc.
There really isn't any way at present to configure these separately based on how the code was written but a PR would be welcome.
Description
I am using kitchen-vagrant with a libvirt box to provision Test Kitchen VMs on a remote KVM hypervisor. To do this, I used the SSH gateway support that was added in #1091.
It appears that there is no way to configure the SSH key used to log in to the gateway.
Kitchen::Transport::Ssh::Connection#establish_connection_via_gateway()
passes the sameoptions
hash to theNet::SSH::Gateway
and to the tunneled connection to the VM. Theoptions
hash sets the SSH key to the Vagrant insecure key.I confirmed that the error is caused by trying to use the Vagrant insecure key to log in to the hypervisor by monkey patching the
Connection
class in my .kitchen.yml. With this change, Test Kitchen successfully connects to the VM.Before I start working on a PR to add a configuration setting for the key to use when connecting to the SSH gateway, I thought I would double check: Is there a way to tell TK which key to use for the SSH gateway, that I have missed?
Kitchen Version
Tell us which version of test-kitchen you are using (
kitchen --version
).Ruby Version
If you are not using test-kitchen via ChefDK, please provide the output of ruby --version.
Platform Version
Mac OS 10.11.6
Replication Case
Configure TK to create the VM on a remote hypervisor (e.g., using vagrant-libvirt) where the hypervisor system does not trust the Vagrant insecure key.
Kitchen Output
Output from when TK tries to log in to the VM after Vagrant sets it up. This repeats every three seconds:
Kitchen Diagnose
https://gist.github.com/aogail/dbe77deeabcdfedefd282764128034fd