Skip to content

feat: wrap ssh with coder key #894

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

Merged
merged 19 commits into from
Apr 7, 2022
Merged

feat: wrap ssh with coder key #894

merged 19 commits into from
Apr 7, 2022

Conversation

f0ssel
Copy link
Contributor

@f0ssel f0ssel commented Apr 6, 2022

What this does

  • On new agent shell session we will set their GIT_SSH_COMMAND environment variable to coder gitssh --. The double dash allows git to pass the command flags and they be ignored by cobra.
  • coder gitssh will grab the user's private key from coderd, write it to a temp file, and run ssh -i /tmp/my-coder-key.
  • Adds a coder publickey command so users can upload this key to their git provider.

@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #894 (dc9fa16) into main (14dec17) will decrease coverage by 0.05%.
The diff coverage is 57.14%.

@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
- Coverage   65.75%   65.70%   -0.06%     
==========================================
  Files         216      215       -1     
  Lines       13834    13725     -109     
  Branches      103      103              
==========================================
- Hits         9097     9018      -79     
+ Misses       3807     3785      -22     
+ Partials      930      922       -8     
Flag Coverage Δ
unittest-go-macos-latest 52.78% <57.14%> (+0.02%) ⬆️
unittest-go-postgres- 65.73% <57.14%> (+0.21%) ⬆️
unittest-go-ubuntu-latest 55.40% <57.14%> (+0.02%) ⬆️
unittest-go-windows-2022 ?
unittest-js 58.87% <ø> (ø)
Impacted Files Coverage Δ
agent/agent.go 66.66% <40.00%> (-0.65%) ⬇️
cli/workspaceagent.go 76.08% <40.00%> (-2.08%) ⬇️
cli/gitssh.go 54.34% <54.34%> (ø)
cli/publickey.go 60.00% <60.00%> (ø)
cli/config/file.go 77.77% <100.00%> (+1.30%) ⬆️
cli/root.go 76.85% <100.00%> (+0.43%) ⬆️
codersdk/gitsshkey.go 50.00% <100.00%> (ø)
cli/configssh.go 50.00% <0.00%> (-8.04%) ⬇️
provisionersdk/transport.go 78.72% <0.00%> (-6.39%) ⬇️
cli/cliui/agent.go 77.19% <0.00%> (-5.27%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14dec17...dc9fa16. Read the comment docs.

@kylecarbs
Copy link
Member

You'll have to pipe the SSH command to cmd.InOrStdin and same for cmd.OutOrStdout, otherwise it can't detect output.

@f0ssel f0ssel closed this Apr 6, 2022
@f0ssel f0ssel reopened this Apr 6, 2022
@f0ssel f0ssel marked this pull request as ready for review April 7, 2022 15:20
@f0ssel f0ssel force-pushed the f0ssel/agent-ssh branch from 93c7238 to b2384e9 Compare April 7, 2022 15:25
@f0ssel f0ssel force-pushed the f0ssel/agent-ssh branch from b2384e9 to dff454c Compare April 7, 2022 15:26
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to abstract agent authentication out of workspaceagent.go, and I think that's the only real blocker here. Other than that, I just had a buncha lil UX knobs to twist.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we agree on all the comments, so I shall approve! Great work on this- 'tis a top-tier feature (if you'd still like my thoughts just tag again).

@kylecarbs
Copy link
Member

@deansheather top-tier review 🏹🏹🏹

@f0ssel f0ssel enabled auto-merge (squash) April 7, 2022 22:27
@f0ssel f0ssel merged commit 38f0742 into main Apr 7, 2022
@f0ssel f0ssel deleted the f0ssel/agent-ssh branch April 7, 2022 22:40
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants