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

bug: Create SSH known_hosts file if doesn't already exist #915

Closed
nschmeller opened this issue Sep 21, 2022 · 1 comment · Fixed by #933
Closed

bug: Create SSH known_hosts file if doesn't already exist #915

nschmeller opened this issue Sep 21, 2022 · 1 comment · Fixed by #933
Assignees
Labels
bug Something isn't working

Comments

@nschmeller
Copy link
Contributor

Describe the bug
Running lacework agent install with the flag --trust_host_key will add the hostname to the list of known hosts if it isn't already known. If ~/.ssh/known_hosts does not exist when this command is run, the CLI will exit with status code 1 and the error ERROR unable to connect to the remote host: ssh: handshake failed: open /root/.ssh/known_hosts: no such file or directory.

To Reproduce
Steps to reproduce the behavior:

  1. Use an environment without .ssh (in this case, a container image didn't have it).
  2. Run lacework agent install ... --trust_host_key
  3. Expect exit code 1 and the error above

Expected behavior
The CLI should create ~/.ssh/known_hosts and then proceed to add the host to that file.

Please complete the following information):

  • OS: container image (earthly/dind:ubuntu)
  • Version [e.g. v0.42.0]
@nschmeller nschmeller added the bug Something isn't working label Sep 21, 2022
@nschmeller nschmeller changed the title bug:Create SSH known_hosts file if doesn't already exist bug: Create SSH known_hosts file if doesn't already exist Sep 21, 2022
@dmurray-lacework
Copy link
Collaborator

Hi @nschmeller thanks for raising this issue, I've opened a Jira on our backlog to take a look at this.

@afiune afiune self-assigned this Oct 5, 2022
afiune added a commit that referenced this issue Oct 5, 2022
Replicated the issue inside our unit tests:
```
=== Failed
=== FAIL: lwrunner TestLwRunnerAddKnownHost (0.19s)
    runner_test.go:132:
        	Error Trace:	/Users/afiune/github/go-sdk/lwrunner/runner_test.go:132
        	Error:      	Received unexpected error:
        	            	open /var/folders/pn/rtky3yx17fx60dc03njhm_fw0000gn/T/lwrunner1052124622/.ssh/known_hosts: no such file or directory
        	Test:       	TestLwRunnerAddKnownHost
```

Relates to #915

Signed-off-by: Salim Afiune Maya <afiune@lacework.net>
afiune added a commit that referenced this issue Oct 5, 2022
This change fixes the issue where we try to add a known host to the
known_hosts file but the directory ~/.ssh does not exist.

Now we are creating that directory first.

Closes #915
Jira https://lacework.atlassian.net/browse/ALLY-1195

Signed-off-by: Salim Afiune Maya <afiune@lacework.net>
afiune added a commit that referenced this issue Oct 7, 2022
**Summary**

This change fixes the issue where we try to add a known host to the
known_hosts file but the directory ~/.ssh does not exist.

Now we are creating that directory first.

**How did you test this change?**

Replicated the issue inside our unit tests:
```
    === Failed
    === FAIL: lwrunner TestLwRunnerAddKnownHost (0.19s)
        runner_test.go:132:
                    Error Trace:    /Users/afiune/github/go-sdk/lwrunner/runner_test.go:132
                    Error:          Received unexpected error:
                                    open /var/folders/pn/rtky3yx17fx60dc03njhm_fw0000gn/T/lwrunner1052124622/.ssh/known_hosts: no such file or directory
                    Test:           TestLwRunnerAddKnownHost
```


**Issue**

Closes #915
Jira https://lacework.atlassian.net/browse/ALLY-1195

Signed-off-by: Salim Afiune Maya <afiune@lacework.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants