-
Notifications
You must be signed in to change notification settings - Fork 259
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
Deploy keys do not work on Windows #62
Comments
Maybe a stupid question but can you write it down to disk, ssh-add, then delete it right after adding it? I understand it is not ideal but it might be an okay workaround for now |
No, it has to be available at a later stage when e.g. Git uses SSH, so after this action here has finished. |
I just made a test locally on Linux and I confirm that the key is actually loaded in memory. You can safely delete the file right after adding it if you want. |
I understand that if you write the keys to disk they become available to whatever runs later in the action, but can you please help me understand why that’s a problem? You should trust the things you’re running anyway, because even if they can’t access the key, they can use it via the agent. You may not be giving people the keys to your house, but you’re leaving the door open. |
Even when you use ssh-agent and share it through ssh (ssh -A), your keys are actually accessible by the remote machine as long as the ssh session is opened. Though to avoid leaking the key by mistake I would simply delete the file right after it is added (if that works on Windows). It works on Linux so I suspect the key is loaded into memory and it doesn't matter if the file is still there. |
Please help testing if the #63 PR fixes the issue for you. In your GHA workflow files, |
It's still failing for me, no change in the error message. Thanks a lot for your time!! |
I will do some investigation too |
Ok it's working. @mpdude with v0.5.0 it fails. So what you did in your branch really made the difference!
With
NOTE for other cargo users, you will need to add this to your workflow before running any cargo command:
@mpdude for me you can merge and close this ticket. Thanks again for your time (cc @fstephany) |
@cecton Thanks for the report! I don't know about Cargo/Rust... but would it make sense to add a section to the README file explaining this (and could you also explain what this change does and why it is necessary then?). Feel free to open a PR for it! |
You're 💯 right, thanks!! |
I think this has been resolved by #63, and just released as Make sure you update your workflow definitions if you have been affected by this. |
Using GitHub deploy keys as described in the README file does not work in Windows. Using "plain" keys (i. e. without the repo mapping provided in the comment) works, but you might be limited in how many of these keys can be tried before the remote server aborts the connection.
When deploy keys are used, this action writes the public key information (as shown by
ssh-add -L
) into a file, and configures SSH viaIdentityFile
to use this identity when connecting to the host. Also,IdentitiesOnly
is turned on to try only the particular key.On Linux systems (at least, the Ubuntu-based virtual action environments) and OS X, this works: It identifies the key to use via the public key part, but fetches the key from the SSH Agent.
On Windows, it fails. Here's the output from the
ssh -v
level:As you can see, SSH on Windows complains that the key is in an invalid format. This is because the file contains the public key part, but
IdentityFile
should point to a private key file.There is a bug report over at PowerShell/Win32-OpenSSH#1550 which describes that
IdentitiesOnly
will make SSH ignore keys from the SSH Agent. However, since removingIdentitiesOnly
in this action here does not solve or work around the issue. So, the two things might be related, but it's not exactly the same problem.One way of working around this would be to write the private key files to disk (at least under Windows), so that
ssh
can pick the right identity from the file. Writing keys to disk or file, however, is something this action has tried to avoid in the first place: With keys on disk, any subsequent action or process might read/steal the key. With the current action design, the private keys are passed right from GitHub Secrets into thessh-agent
process and cannot be recovered from there later on. So, I'm a bit reluctant to make this change.I can raise an issue over at https://github.com/PowerShell/Win32-OpenSSH/, however I have no idea if this is the right place to report, how quickly the issue could be fixed and when an update would make it into virtual Windows environments.
The text was updated successfully, but these errors were encountered: