-
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
Run inside a Docker container #20
Comments
Does it work if we put the keys into That should be the system (not user specific) file and we could get around all attempts to detect the user and/or |
Correction: That file might be |
Right, it also works if I try |
Hi Are there any updates on this? I'm about to roll out github actions to ~20 packages so it would be nice if I can skip the |
No progress, I’m afraid. This is open source, so we place the utmost reliance upon the zealous cooperation of the public. If, however, you can provide a pull request, I’d be happy to review it! What if we try to write to both known_hosts file locations, ignoring errors? Would that solve it? |
I am experiencing the same issue but not when running in a container.
|
I should have read this more carefully as I spent the same time trying to track this down one run after another 😄 |
I am trying to use Packer:
but it doesn't have access to the SSH keys. Is there a way to achieve this? |
Thank you @rieschl for your suggestion and working on this, and thanks to @mwik for creating #58 for it! The code change suggested in the opening comment here looks like some specialized edge case logic... I wonder if we could find a more general, cleaner way of dealing with this? I understand that So, what does |
Oh, and does it make a difference inside the container when we're using |
That's the question. $HOME points to /github/home, but ssh nevertheless looks in /root/.ssh so figuring out why is key. #58 is only a workaround. Unfortunately it is a PITA to debug stuff in github actions. However it seems that ssh does not like changing HOME, it still uses the old value somehow. I don't think it will matter whether we use os.homedir() or HOME since its set to the same thing. |
Come to think of it, ssh probably uses getent or something similar to get the home directory of the current user. Probably that is not changed in the container. |
After inspecting the ssh source code I can confirm that it uses the passwd entry. I also found that we can actually use delete process.env['HOME'];
const homeSsh = os.homedir() + '/.ssh'; I'll test this when I have an opportunity. |
Unfortunately HOME needs to be undefined in order for |
I haven’t found good „official“ documentation or even source code in this, but it seems So, maybe we should use |
Great! |
Out of curiosity, how is the action run inside the container – is it a requirement for such containers to contain the |
It works 🎉, @mwik thank you for the support! https://github.com/webfactory/ssh-agent/runs/1893563200?check_suite_focus=true |
Very good question. Node is not installed in my build docker image, so I assume its mounted somewhere. Strangely enough I can not find any documentation about how its done. |
Maybe they do some tricks like mounting a statically-linked version somewhere... |
It took me forever to figure out, why this action doesn't work if I run the whole workflow inside a container.
The problem is that the Github Action somehow changes/sets the
HOME
variable inside the container so that the~/.ssh/known_hosts
file is at a wrong location.This action puts the Github PubKeys inside
~/.ssh/known_hosts
which is in the home path of the runner. But the running container normally runs asroot
so ssh looks for/root/.ssh/known_hosts
which doesn't exist.Copying the
known_hosts
to this location if the workflow is running inside Docker solves the problem. As I am a total Node noob I just played around with thedist/index.js
file, but putting the following snippet after creating theknown_hosts
file the SSH agent also works inside docker:I'm not sure if that somehow breaks running the action in Windows because in Windows there is no
id
command. But that shouldn't be a problem because Github Actions currently doesn't allow running non-Linux containers. Also, I don't know if theroot
check is even necessary because probably all containers run as root.Would it be possible to add this snippet to your action so Docker users can also use it? :)
The text was updated successfully, but these errors were encountered: