Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable execute inspec profile using ssh from jenkins node. #528

Open
esaravanakumar89 opened this issue Oct 30, 2019 · 7 comments
Open

unable execute inspec profile using ssh from jenkins node. #528

esaravanakumar89 opened this issue Oct 30, 2019 · 7 comments

Comments

@esaravanakumar89
Copy link

esaravanakumar89 commented Oct 30, 2019

🎛unable execute inspec profile using ssh from jenkins node using withCredentials plugin using filebinding.

Choose one: is this a 🐛 bug report or 🙋 feature request?
bug
Briefly describe the issue and the expected behavior. Also, please be aware of our Code of Conduct.

withCredentials([[$class: 'FileBinding', credentialsId: 'username', variable: 'filekey_path']]) {

inspec exec test_profile -i ${env.filekey_path} --diagnose --log-level=debug --sudo -t ssh://testuesr@testserver

}

Client error, can't connect to 'ssh' backend: Your SSH Agent has no keys added, and you have not specified a password or a key file

Same env.key_file is working when i connect through ssh (ssh -i) from the jenkins node.

🌍 InSpec and Platform Version

Tell us which version of InSpec (inspec version or SHA of a commit) and Operating System distribution you are using

inspec 2.1.72

OS: rhel7

🤔 Replication Case

Tell us what steps to take to replicate your problem. See How to create a Minimal, Complete, and Verifiable example
for information on how to create a good replication case.

try to execute inspec remote validation from jenkins node.

💁 Possible Solutions

If you have already ideas how to solve the issue, add them here.

💻 Stacktrace

Please include the stacktrace output or link to a gist of it, if there is one.

@frezbo
Copy link
Contributor

frezbo commented Oct 31, 2019

@esaravanakumar89 you have to use ${filekey_path}. ${env.<key>} is for groovy interpolations mostly. I also don't see the command being executed inside a sh block. This would be the syntax I would use:

withCredentials([file(credentialsId: 'username', variable: 'filekey_path')]) {
  sh 'inspec exec test_profile -i ${filekey_path} --diagnose --log-level=debug --sudo -t ssh://testuesr@testserver'
}

@aaronlippold
Copy link
Collaborator

aaronlippold commented Oct 31, 2019 via email

@frezbo
Copy link
Contributor

frezbo commented Oct 31, 2019

@aaronlippold that sh is the jenkins dsl for executing shell commands, it's upto the user to select the interpreter.

Eg:

sh '''#!/bin/bash -l
<commands>
'''

@esaravanakumar89
Copy link
Author

esaravanakumar89 commented Oct 31, 2019 via email

@zenspider
Copy link
Contributor

Moving this issue to train.

@zenspider zenspider transferred this issue from inspec/inspec Oct 31, 2019
@zenspider zenspider added Transport/SSH Type: Bug Feature not working as expected Platform: SSH and removed Transport/SSH labels Nov 12, 2019
@clintoncwolfe
Copy link
Contributor

Outside of a Jenkins setup, I am able to successfully use InSpec 4.18.100 and train 3.2.23 to run inspec detect on a Vagrant virtual machine:

inspec detect -t ssh://[email protected]:2222 -i ../vagrants/ubuntu-16/.vagrant/machines/default/virtualbox/private_key

detect simply connects and runs platform detection, which would be enough to trigger the issue you are reporting; but here it does not.

@clintoncwolfe clintoncwolfe added Type: Support and removed Type: Bug Feature not working as expected labels Mar 3, 2020
@esaravanakumar89
Copy link
Author

esaravanakumar89 commented Mar 3, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants