-
Notifications
You must be signed in to change notification settings - Fork 987
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
Changes from 1 commit
b7bc639
c270898
6c10fa4
9ebf840
d85dc66
e203bf0
a90d3d6
e07d204
216c028
a0f70de
17c7f99
ed5ff26
130ddfd
9c6cfba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,7 +239,7 @@ func ssh() *cobra.Command { | |
cliflag.BoolVarP(cmd.Flags(), &shuffle, "shuffle", "", "CODER_SSH_SHUFFLE", false, "Specifies whether to choose a random workspace") | ||
_ = cmd.Flags().MarkHidden("shuffle") | ||
cliflag.BoolVarP(cmd.Flags(), &forwardAgent, "forward-agent", "A", "CODER_SSH_FORWARD_AGENT", false, "Specifies whether to forward the SSH agent specified in $SSH_AUTH_SOCK") | ||
cliflag.BoolVarP(cmd.Flags(), &forwardGPG, "forward-gpg", "G", "CODER_SSH_FORWARD_GPG", false, "Specifies whether to forward the GPG agent. Unsupported on Windows workspaces, but supports all clients. Requires gnupg (gpg, gpgconf) on both the client and workspace. The GPG agent must already be running and will not be started for you.") | ||
cliflag.BoolVarP(cmd.Flags(), &forwardGPG, "forward-gpg", "G", "CODER_SSH_FORWARD_GPG", false, "Specifies whether to forward the GPG agent. Unsupported on Windows workspaces, but supports all clients. Requires gnupg (gpg, gpgconf) on both the client and workspace. The GPG agent must already be running locally and will not be started for you. If a GPG agent is already running in the workspace, it will be attempted to be killed. It is recommended that you set GPG_TTY, TTY or SSH_TTY to $(tty) beforehand.") | ||
cliflag.StringVarP(cmd.Flags(), &identityAgent, "identity-agent", "", "CODER_SSH_IDENTITY_AGENT", "", "Specifies which identity agent to use (overrides $SSH_AUTH_SOCK), forward agent must also be enabled") | ||
cliflag.DurationVarP(cmd.Flags(), &wsPollInterval, "workspace-poll-interval", "", "CODER_WORKSPACE_POLL_INTERVAL", workspacePollInterval, "Specifies how often to poll for workspace automated shutdown.") | ||
return cmd | ||
|
@@ -448,6 +448,13 @@ func uploadGPGKeys(ctx context.Context, sshClient *gossh.Client) error { | |
set -eux | ||
agent_socket=$(gpgconf --list-dir agent-socket) | ||
echo "$agent_socket" | ||
if [ -S "$agent_socket" ]; then | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I found that sometimes |
||
fi | ||
|
||
test ! -S "$agent_socket" | ||
`) | ||
agentSocket := strings.TrimSpace(string(agentSocketBytes)) | ||
|
Uh oh!
There was an error while loading. Please reload this page.