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

mount-ssh-agent: true -> SSH_AUTH_SOCK: unbound variable #112

Closed
Globegitter opened this issue Mar 15, 2019 · 3 comments
Closed

mount-ssh-agent: true -> SSH_AUTH_SOCK: unbound variable #112

Globegitter opened this issue Mar 15, 2019 · 3 comments

Comments

@Globegitter
Copy link

I want to be able to clone private git repositories within my ci builds and tried to set mount-ssh-agent: true but all I am seeing is:
/buildkite/plugins/github-com-buildkite-plugins-docker-buildkite-plugin-v3-0-1/hooks/command: line 169: SSH_AUTH_SOCK: unbound variable, is there anything I need to set up in the agent for this to work?

@benesch
Copy link
Contributor

benesch commented Mar 28, 2019

Yeah, you'll need to 1) launch an SSH agent that your buildkite-agent user has access to, and 2) set the SSH_AUTH_SOCK variable to point at the SSH agent's socket. Are you using systemd to run buildkite-agent? Here's the unit files I'm using:

# /etc/systemd/system/ssh-agent.conf
[Unit]
Description=SSH agent for Buildkite
Before=buildkite-agent.target

[Service]
Type=simple
User=buildkite-agent
Environment=SSH_AUTH_SOCK=/var/lib/buildkite-agent/.ssh-agent.sock
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
ExecStartPost=/usr/bin/ssh-add

[Install]
WantedBy=buildkite-agent.target

# /etc/systemd/system/buildkite-agent.service.d/override.conf 
[Service]
Environment=SSH_AUTH_SOCK=/var/lib/buildkite-agent/.ssh-agent.sock

Then just run systemctl enable ssh-agent && systemctl restart buildkite-agent and you should be off to the races.

@Globegitter
Copy link
Author

I am running this in a kubernetes cluster but this should give me some idea on how to get this running - thanks. Would be great to have something about this in the readme.

@toote
Copy link
Contributor

toote commented Sep 19, 2022

I have added a clarification on the matter with a link to the Agent's documentation on SSH keys in PR #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants