From be3995e969e16eac08c3e1d0fbaadb60244a5576 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Fri, 7 Apr 2023 22:38:07 -0400 Subject: [PATCH] fix(core): Error when open SSH session on Windows (#293) * fix(core): Error when open SSH session on Windows * update PR template --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- proxmox/virtual_environment_nodes.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 83db7475..5fc0c4ac 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,7 +3,7 @@ Please mark the following items with an [x] if they apply to your PR. Leave the [ ] if they are not applicable, or if you have not completed the item. - [ ] I have added / updated documentation in `/docs` for any user-facing features or additions. - [ ] I have added / updated templates in `/examples` for any new or updated resources / data sources. - - [ ] I have ran `make examples` to verify that the change works as expected. +- [ ] I have ran `make examples` to verify that the change works as expected. ### Community Note diff --git a/proxmox/virtual_environment_nodes.go b/proxmox/virtual_environment_nodes.go index 9ef5ecd8..0494b8f0 100644 --- a/proxmox/virtual_environment_nodes.go +++ b/proxmox/virtual_environment_nodes.go @@ -194,8 +194,12 @@ func (c *VirtualEnvironmentClient) OpenNodeShell( ur := strings.Split(c.Username, "@") + homeDir, err := os.UserHomeDir() + if err != nil { + return nil, fmt.Errorf("failed to determine the home directory: %w", err) + } sshHost := fmt.Sprintf("%s:22", *nodeAddress) - khPath := fmt.Sprintf("%s/.ssh/known_hosts", os.Getenv("HOME")) + khPath := fmt.Sprintf("%s/.ssh/known_hosts", homeDir) kh, err := knownhosts.New(khPath) if err != nil { return nil, fmt.Errorf("failed to read %s: %w", khPath, err)