-
Notifications
You must be signed in to change notification settings - Fork 891
feat: add GPG forwarding to coder ssh #5482
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
Conversation
I rarely use GPG anymore, but this is cool! Are you planning on fixing the I think testing should be possible by generating the GPG config ( Re: agent forwarding on Windows, #4007. |
I have written working agent forwarding in coder v1 on windows in the past so I'll try to implement that here too. |
This is cool (tm) specifically ability to forward YubiKeys/SmartCards for signing of commits. <3 |
That would be nice. SO people are actually using YubiKeys. |
I wrote a working test for Linux. I think writing a test for Windows will be much harder so I've avoided it and will stick to manually testing it instead, which I'll do tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I only took a quick look as it's getting pretty late, I'll take another one tomorrow 👍🏻!
I've tested on windows, linux and darwin and it works. I couldn't get it to work with TTY-based pinentry (such as Video from windows: firefox_Ba0si3hbaN.mp4Video from darwin: Screen_Recording_2023-01-05_at_10.57.44_pm.mp4No linux video because I forgot to record one. You'll have to trust me that it works 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on this feature! Spotted some minor stuff but other than that this looks good to go.
My only complaint is the GPG password length on your Mac! 😉
}, testutil.WaitLong, testutil.IntervalFast) | ||
|
||
conn, err := net.Dial("unix", remoteSocketPath) | ||
require.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
cli/ssh.go
Outdated
echo "agent socket exists, attempting to kill it" >&2 | ||
gpgconf --kill gpg-agent | ||
rm -f "$agent_socket" | ||
sleep 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the sleep purposeful here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that sometimes gpgconf --kill gpg-agent
didn't instantly kill the agent while testing one time so I added the sleep. I think 1 second should be enough though
@deansheather Great work! Regarding Yubico key forwarding, I agree, that would be AWESOME! Thank you! |
This is a port of some really old code (since deleted) from Coder v1. Allows for forwarding GPG keys from the local machine to the workspace on both Linux and Windows (which has a more complicated process than Linux).
--forward-gpg
/-G
flag tocoder ssh
TODO:
I will do a follow-up PR to fix SSH forwarding on Windows (I don't think it works ATM)