Inspec -t ssh not possible

Hey there,

I'm trying to setup inspec over ssh.
What I already did:

  • SSH-Key is deployed on the server under [username]
  • installed inspec
  • created alias: alias inspec='docker run -it --rm -v $HOME:/share chef/inspec'

$ inspec version
2.0.32

inspec exec linux-baseline/ -t ssh://[username]@[ip]:[ssh-port] -i ~/.ssh/[pathtokey]/name_id_rsa --debug -l debug

Inspec says:

D, [2018-03-02T14:33:27.401995 #1] DEBUG -- : [SSH] [username>@[ip>
[{:user_known_hosts_file=>"/dev/null", :port=>[ssh-port], :compression=>false, :compression_level=>0,
:keepalive=>true, :keepalive_interval=>60, :timeout=>15, :auth_methods=>["none", "publickey"],
:keys_only=>true, :keys=>["/home/[user]/.ssh/[pathtokey]/name_id_rsa"], :password=>"[hidden>",
:forward_agent=>nil, :verify_host_key=>false}> (uname -s)

Server says:

Mar 2 15:33:02 [hostname] sshd[17147]: Connection from inspect-runner] port 58568 on [ip] port [ssh-port]
Mar 2 15:33:02 [hostname] sshd[17147]: Connection closed by [inspect-runner] port 58568 [preauth]strong text

You are sharing $HOME into /share in the Docker container but the user that InSpec runs under in the container is root so its home directory is /root which means that ssh will look for keys under /root/.ssh

1 Like