-
Notifications
You must be signed in to change notification settings - Fork 391
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
Feature Request: Private SSH Dependencies #401
Comments
The SSH Agent socket can be forwarded using the following options to Docker run:
It would be nice to have an option in Cross.toml that runs the build with this on the docker command line. |
How exactly did you accomplish that? With a setting in |
I have not accomplished this, this is a feature request. I'll edit the title to clarify that |
Found a solution, cross allows to specify custom commands to the docker container being run through DOCKER_OPTS env variable. So for me using fish shell:
you should see your ssh agent in the output from there since I added the verbose flag |
I've tried your solution, but I am hitting the following error:
On [build.env]
passthrough = [
"SSH_AUTH_SOCK",
"SSH_AGENT_PID",
"CARGO_NET_GIT_FETCH_WITH_CLI",
] Without The
Now I don't really know what to do. I checked the docker images and they all have dropbear. |
I believe this is your issue, since |
So I've created a sample repository and commit to provide this feature. I have a private dependency private_lib (obviously, you won't be able to access this) and a binary that depends on this. The variable name maybe should be renamed, and obviously this needs to be tested on more hosts. Since cargo itself doesn't store git credentials (to my knowledge, this may have changed recently), and SSH is often not installed on the prebuilt images, I doubt it's a good idea to provide credentials manually in the configuration file. This could accidentally expose secrets, and would likely require more work. Attempting to build with the default cross produces:
However, using cross installed from the SSH branch allows the SSH agent to be passed to the container (and therefore to cross):
This works by adding a config variable |
It seems like we might need to canonicalize Unfortunately, docker provides a much better way... but only when building images, using the We might also want to mount this in |
This works on WSL, but it won't work on Windows more generally since it doesn't export |
the pipe can be found with
which should always be just that. It's a windows pipe though, and i'm not sure it will carry across with the CE |
This was unexpectedly fixed in #684, and without needing to forward any SSH credentials. You can test it works with the following in a crate with a private SSH dependency. eval `ssh-agent`
ssh-add /path/to/key
cargo metadata --format-version=1 --filter-platform arm-unknown-linux-gnueabihf
# kill the SSH agent, to ensure it works
eval `ssh-agent -k`
cross build --target arm-unknown-linux-gnueabihf No environment variable forwarding required, which should make this much more resilient. |
I ran into a wall when trying to compile a project with dependencies on private Git repositories. Since these require the use of my private key they fail.
It would be nice if we could specify a private key to forward in Cross.toml - or forward the socket to the SSH agent.
The text was updated successfully, but these errors were encountered: