# SSH when using self hosted runner on k8s

**URL:** <https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772>\
**Category:** Build Environment\
**Created:** [November 3, 2023, 9:43pm UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772 "2023-11-03T21:43:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sibelius](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/sibelius/32/13734_2.png) [@sibelius](https://discuss.circleci.com/u/sibelius)\
**Post date:** [November 3, 2023, 9:43pm UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772/1 "2023-11-03T21:43:42Z")

</div>

how to enable ssh when using self hosted runner on k8s ?

I’m getting this error

Failed to enable SSH: Oops - looks like we misconfigured our instances and ssh isn’t enabled properly for this build. If the problem persists, please contact our support.

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [November 3, 2023, 10:52pm UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772/2 "2023-11-03T22:52:55Z")

</div>

That looks like a very unhelpful ‘general’ error.

When you say enable ssh, in what way?

One of the stated limitations is “The ability to rerun a job with SSH”

> **[Container runner reference - CircleCI](https://circleci.com/docs/container-runner/#limitations)**
>
> Details of CircleCI's container runner

This does make sense as while you are running the circleci agent within your defined environment it has no control over the environment it is being run in, so no way to allow remote ssh connections into the container.

One thing to note is that the SSH debugging feature is an embedded SSH server within the agent (for a normal runner), so wants a fixed dedicated nonstandard port to be made available. This is OK for their dedicated systems, but something I have left disabled for my VM-based runners as my runners do not have public IP addresses and so can not accept an external connection.

---

<div class="post-metadata">

**Author:** ![sibelius](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/sibelius/32/13734_2.png) [@sibelius](https://discuss.circleci.com/u/sibelius)\
**Post date:** [November 6, 2023, 11:09am UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772/3 "2023-11-06T11:09:32Z")

</div>

is there a guide for this? to enable this on k8s ?

just kubectl ssh inside the pod ?

---

<div class="post-metadata">

**Author:** ![wyardley](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/wyardley/32/19231_2.png) [@wyardley](https://discuss.circleci.com/u/wyardley)\
**Post date:** [November 8, 2023, 12:02am UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772/4 "2023-11-08T00:02:40Z")

</div>

I think the point is that it’s a known limitation the “build with ssh” UI option won’t work with self-hosted executors, so you’d get remote access to that host / container however you normally would vs. using that feature. From a security standpoint, this is also probably the better / safer way, though I do wish CircleCI would not show the UI option to re-run the job with ssh when the job has used a self-hosted executor, since it will let you _try_ to do it.

In the case of a kubernetes hosted runner, I wouldn’t ssh to it, but rather exec into the container if you need to for some reason (`kubectl exec -it -n yournamespace -n pod-id -- /bin/bash` or similar).

---

<div class="post-metadata">

**Author:** ![christian-stephen](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/christian-stephen/32/34643_2.png) [@christian-stephen](https://discuss.circleci.com/u/christian-stephen)\
**Post date:** [December 8, 2023, 10:59am UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772/5 "2023-12-08T10:59:34Z")

</div>

Hey all, SSH reruns for container runner is now in [open preview](https://circleci.com/docs/container-runner-installation/#enable-rerun-job-with-ssh).

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [January 17, 2024, 7:17pm UTC](https://discuss.circleci.com/t/ssh-when-using-self-hosted-runner-on-k8s/49772/6 "2024-01-17T19:17:39Z")

</div>

Closed on January 17, 2024, 7:17pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
