# Accessing SSH keys within

**URL:** <https://discuss.circleci.com/t/accessing-ssh-keys-within/33562>\
**Category:** Build Environment\
**Tags:** docker, ssh\
**Created:** [November 29, 2019, 12:47pm UTC](https://discuss.circleci.com/t/accessing-ssh-keys-within/33562 "2019-11-29T12:47:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haelium](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/haelium/32/23720_2.png) [@Haelium](https://discuss.circleci.com/u/Haelium)\
**Post date:** [November 29, 2019, 12:47pm UTC](https://discuss.circleci.com/t/accessing-ssh-keys-within/33562/1 "2019-11-29T12:47:15Z")

</div>

The documentation here: [https://circleci.com/docs/2.0/add-ssh-key/](https://circleci.com/docs/2.0/add-ssh-key/) on adding SSH keys is really not sufficient.

When I add an SSH key in this method, how can I access it within the container? My usecase is the following:

I have a multistage dockerfile which builds a container. The builder requires access to a private repo, so a private SSH key is required as a build argument.

It appears that the SSH key added to the circleci build container is not in ~/.ssh, as you would expect, so is it set as an environment variable? If so, what is the label for this environment variable?

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [November 30, 2019, 9:06pm UTC](https://discuss.circleci.com/t/accessing-ssh-keys-within/33562/2 "2019-11-30T21:06:17Z")

</div>

> [@Haelium](#):
>
> I have a multistage dockerfile which builds a container. The builder requires access to a private repo, so a private SSH key is required as a build argument.

For this specific use case, I would suggest adding a user key. You can do this from the project settings page:

[https://circleci.com/gh/$ORG/$REPO/edit#checkout](https://circleci.com/gh/$ORG/$REPO/edit#checkout)

---

<div class="post-metadata">

**Author:** ![Haelium](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/haelium/32/23720_2.png) [@Haelium](https://discuss.circleci.com/u/Haelium)\
**Post date:** [December 1, 2019, 5:30pm UTC](https://discuss.circleci.com/t/accessing-ssh-keys-within/33562/3 "2019-12-01T17:30:14Z")

</div>

Thanks Levlaz, that’s helpful.

However it still leaves an open question: What is the environment variable label, or the location of the key within the circleci root container?

I need to actually pass the key as a build-arg when I build using a dockerfile.

---

<div class="post-metadata">

**Author:** ![tkwon](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tkwon/32/22174_2.png) [@tkwon](https://discuss.circleci.com/u/tkwon)\
**Post date:** [March 2, 2020, 11:10pm UTC](https://discuss.circleci.com/t/accessing-ssh-keys-within/33562/4 "2020-03-02T23:10:34Z")

</div>

Looking for the answer also. How/where is the ssh key? I’m running a fabric script and need to do “fab mycommand(path to ssh key)”

---

<div class="post-metadata">

**Author:** ![ducdhm](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ducdhm/32/33272_2.png) [@ducdhm](https://discuss.circleci.com/u/ducdhm)\
**Post date:** [June 22, 2023, 7:20am UTC](https://discuss.circleci.com/t/accessing-ssh-keys-within/33562/5 "2023-06-22T07:20:40Z")

</div>

I have same issue with you and I found the location which store all information. Please check `.circleci-runner-config.json` at root
