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

Broken authorization of standard SSH public keys on Windows #150

Open
3 tasks
lukasfazik opened this issue Dec 4, 2024 · 0 comments · May be fixed by #151
Open
3 tasks

Broken authorization of standard SSH public keys on Windows #150

lukasfazik opened this issue Dec 4, 2024 · 0 comments · May be fixed by #151

Comments

@lukasfazik
Copy link

Description
The function authorizeSSHKeyStandard() in context.ps1 (context-windows) uses $env:USERPROFILE variable when storing the user's public key. Because the contextualization service runs as a local system account, the resulting value for this environment variable is C:\WINDOWS\system32\config\systemprofile\, which is not expected behavior.

Also, the function uses .ssh folder instead of authorized_keys file when calling Set-Content cmdlet to write the public keys into a file. This operation fails.

To Reproduce

  • Prepare Windows virtual machine
  • Install OpenNebula context
  • Add public SSH key into context
  • Add WINADMIN = "NO" context variable
  • Wait 30+ seconds for context to run and pick up the changes
  • See that context portion for setting the SSH key fails and no authorized_keys file is created

Expected behavior
The USERNAME context variable should be used instead (like in context-linux). Also, a check should be performed to see if the user profile exists before forcefully creating .ssh directory. This avoids messing up the permissions for the future user profile directory.

Details

  • Affected Component: context-windows
  • Version: 6.10.0-2

Additional context

  • OpenNebula context log representing the issue: opennebula-context.log
  • Windows has a default setting for SSH Service that all users belonging to the Administrators group share the authorized SSH keys from %PROGRAMDATA%\ssh\admin_authorized_keys. So this feature needs to be disabled when WINADMIN = "NO" since context adds the user in USERNAME context variable to the Administrators group.
  • Microsoft docs for SSH in Windows

Progress Status

  • Code committed
  • Testing - QA
  • Documentation (Release notes - resolved issues, compatibility, known issues)
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.

1 participant