Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Access the workspace user's SSH key inside a Terraform template #3318

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

Closed
sharkymark opened this issue Jul 30, 2022 · 7 comments
Closed

Access the workspace user's SSH key inside a Terraform template #3318

sharkymark opened this issue Jul 30, 2022 · 7 comments
Labels
api Area: HTTP API stale This issue is like stale bread.

Comments

@sharkymark
Copy link
Contributor

A community member posted in Coder's Discord channel asking whether there is a way to access a user's public and private SSH key from within Terraform.

@kylecarbs responded it is not in the project today, but suggested filing an issue, so I am creating the issue for this user.

@kylecarbs kylecarbs changed the title feat: access the workspace user's public (or private) SSH key inside Terraform template Access the workspace user's SSH key inside a Terraform template Aug 24, 2022
@kylecarbs kylecarbs added the api Area: HTTP API label Aug 24, 2022
@jaulz
Copy link

jaulz commented Aug 26, 2022

Yeah, I just stumbled across the exact same issue. That would be very helpful in order to sign git commits.

@github-actions
Copy link

This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label Oct 26, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2022
@kylecarbs kylecarbs reopened this Dec 13, 2022
@github-actions github-actions bot removed the stale This issue is like stale bread. label Dec 13, 2022
@RickyGrassmuck
Copy link
Contributor

Think this is the right issue to comment on about my situation.

Running into a Chicken/Egg situation myself in my current project. Here's the scenario:

  1. The workspace we are creating starts from a base VM image
  2. In order to provision a dev environment, we need to clone a repository onto the VM once it's spun up and run a script from that repo which is responsible for creating the dev environment and includes cloning other repos onto the VM.
  3. The dev env setup process requires the public key being used to clone the repos to be added to our users account in our git provider.

Current struggles

The current template is setup to use the Coder Agent startup_script and functionally this works but has some downsides that make the UX sub-optimal.

First, a relatively minor inconvenience, is the user has to add the new public key to all git hosts that they need to pull down repos from. This adds the overhead of having to manage another key across your providers in the event that something requires it to be changed.

The second, and more complicated situation, stems from having to run the setup script as the coder_agent startup script. In my current scenario, the meat of the "provisioning" process is running that script and because the workspace's status and available output is limited to the Terraform provisioning steps, we end up with workspaces that show to be deployed but do not have any way of seeing the output or status of our start up script to see if the dev environment was properly setup (Basically just have to wait for the interface to show the coder agent running and then login and check manually if things worked out).

Potential Solution Thoughts

The key being pregenerated by coder isn't really a problem but not having the ability to utilize those keys until the Coder Agent is running means that provisioning steps that would be best suited for inclusion in the Terraform run are not possible without having the user supply a private key directly to Terraform to use for any resources that would need them (which I'm personally opposed to).

I'm not sure what the best solution is here as I could see there being a number of ways of addressing it but I did have one workflow idea that made sense in my head.

The idea is to have an option in the coder_agent resource that directs it to install the private key into the workspace users home directory automatically as part of the startup process. Couple this with a new Terraform resource that simply waits for the coder agent to report that it's finished starting successfully (probably through an API call to the coder server), templates would then be able to make additional provisioning steps depend on this resource to ensure that when they run the users SSH key is installed on the system for them to make use of.

Sorry for the wall of text, wanted to take a break from working on the problem to brain dump here before jumping back into working on it again lol.

@github-actions
Copy link

This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label Mar 21, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2023
@mattlqx
Copy link

mattlqx commented Mar 28, 2023

bump

@matifali
Copy link
Member

Any thoughts on reopening this? Or any other related issue that covers this case? @bpmct @sharkymark

@bpmct
Copy link
Member

bpmct commented Mar 28, 2023

Ah whoops - we plan on doing this. There is also a current workaround. See this (still open) issue: #5599

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API stale This issue is like stale bread.
Projects
None yet
Development

No branches or pull requests

7 participants