Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite7a1c7b

Browse files
mafredrikylecarbs
authored andcommitted
feat: Add support for--identity-agent incoder ssh (#1954)
1 parent184dba6 commite7a1c7b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

‎cli/ssh.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func ssh() *cobra.Command {
3434
stdiobool
3535
shufflebool
3636
forwardAgentbool
37+
identityAgentstring
3738
wsPollInterval time.Duration
3839
)
3940
cmd:=&cobra.Command{
@@ -110,8 +111,11 @@ func ssh() *cobra.Command {
110111
returnerr
111112
}
112113

113-
ifforwardAgent&&os.Getenv("SSH_AUTH_SOCK")!="" {
114-
err=gosshagent.ForwardToRemote(sshClient,os.Getenv("SSH_AUTH_SOCK"))
114+
ifidentityAgent=="" {
115+
identityAgent=os.Getenv("SSH_AUTH_SOCK")
116+
}
117+
ifforwardAgent&&identityAgent!="" {
118+
err=gosshagent.ForwardToRemote(sshClient,identityAgent)
115119
iferr!=nil {
116120
returnxerrors.Errorf("forward agent failed: %w",err)
117121
}
@@ -171,6 +175,7 @@ func ssh() *cobra.Command {
171175
cliflag.BoolVarP(cmd.Flags(),&shuffle,"shuffle","","CODER_SSH_SHUFFLE",false,"Specifies whether to choose a random workspace")
172176
_=cmd.Flags().MarkHidden("shuffle")
173177
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")
178+
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")
174179
cliflag.DurationVarP(cmd.Flags(),&wsPollInterval,"workspace-poll-interval","","CODER_WORKSPACE_POLL_INTERVAL",workspacePollInterval,"Specifies how often to poll for workspace automated shutdown.")
175180

176181
returncmd

‎cli/ssh_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ func TestSSH(t *testing.T) {
146146

147147
<-cmdDone
148148
})
149-
//nolint:paralleltest // Disabled due to use of t.Setenv.
150149
t.Run("ForwardAgent",func(t*testing.T) {
151150
ifruntime.GOOS=="windows" {
152151
t.Skip("Test not supported on windows")
153152
}
154153

154+
t.Parallel()
155+
155156
client,workspace,agentToken:=setupWorkspaceForSSH(t)
156157

157158
_,_=tGoContext(t,func(ctx context.Context) {
@@ -198,11 +199,11 @@ func TestSSH(t *testing.T) {
198199
}
199200
})
200201

201-
t.Setenv("SSH_AUTH_SOCK",agentSock)
202202
cmd,root:=clitest.New(t,
203203
"ssh",
204204
workspace.Name,
205205
"--forward-agent",
206+
"--identity-agent",agentSock,// Overrides $SSH_AUTH_SOCK.
206207
)
207208
clitest.SetupConfig(t,client,root)
208209
pty:=ptytest.New(t)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp