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

--sudo flag not doing anything with cnspec scan ssh #296

Closed
tas50 opened this issue Oct 16, 2022 · 3 comments · Fixed by #337
Closed

--sudo flag not doing anything with cnspec scan ssh #296

tas50 opened this issue Oct 16, 2022 · 3 comments · Fixed by #337
Assignees

Comments

@tas50
Copy link
Member

tas50 commented Oct 16, 2022

Describe the bug
I'm trying to scan a Linux host over ssh and that requires using Sudo to elevate my privs. I assumed I should just add the --sudo flag to my scan ssh command, but it's not working and not producing any errors either.

To Reproduce
Steps to reproduce the behavior:

  1. cnspec scan ssh SOME_HOST_IP --incognito --sudo

Expected behavior
Either an error that passwordless sudo is not enabled or a prompt for the sudo password.

Desktop (please complete the following information):

  • OS: macOS
@chris-rock
Copy link
Member

move this to cnquery since the problem is located there

@chris-rock chris-rock transferred this issue from mondoohq/cnspec Oct 16, 2022
@czunker czunker self-assigned this Oct 19, 2022
@czunker
Copy link
Contributor

czunker commented Oct 19, 2022

Simple cnquery command to reproduce:

cnquery run ssh --sudo -i /home/christian/workspace/mondoo/examples/.vagrant/machines/default/virtualbox/private_key vagrant@127.0.0.1:2222 -c "file('/root/.profile'){ exists }"
→ discover related assets for 1 asset(s)
→ resolved assets resolved-assets=1
Query encountered errors:
1 error occurred:
	* permission denied
file: {
  exists: permission denied
}

@czunker
Copy link
Contributor

czunker commented Oct 19, 2022

This also affected local:

c run local --sudo -c "file('/root/.profile'){ exists }"                                                                     ✔ │ 09:23:47 
→ discover related assets for 1 asset(s)
→ resolved assets resolved-assets=1
Query encountered errors:
1 error occurred:
	* stat /root/.profile: permission denied
file: {
  exists: stat /root/.profile: permission denied
}

czunker added a commit that referenced this issue Oct 19, 2022
Fixes #296

Signed-off-by: Christian Zunker <christian@mondoo.com>
chris-rock pushed a commit that referenced this issue Oct 19, 2022
Fixes #296

Signed-off-by: Christian Zunker <christian@mondoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants