Skip to content
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

[v15] Fix Paramiko and SSH multiplexer agent support #44672

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/tbot/service_ssh_multiplexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,19 @@ func (s *SSHMultiplexerService) generateIdentity(ctx context.Context) (*identity
if err != nil {
return nil, trace.Wrap(err, "adding identity to agent")
}
// There's a bug with Paramiko and older versions of OpenSSH that requires
// that the bare key also be included in the agent or the key with the
// certificate will not be used.
// See the following: https://bugzilla.mindrot.org/show_bug.cgi?id=2550
err = newAgent.Add(agent.AddedKey{
PrivateKey: id.PrivateKey,
Certificate: nil,
LifetimeSecs: 0,
})
if err != nil {
return nil, trace.Wrap(err, "adding bare key to agent")
}

s.agentMu.Lock()
s.agent = newAgent.(agent.ExtendedAgent)
s.agentMu.Unlock()
Expand Down
6 changes: 6 additions & 0 deletions lib/tbot/tbot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@ func TestBotSSHMultiplexer(t *testing.T) {
out, err := sshSess.CombinedOutput("echo hello")
require.NoError(t, err)
require.Equal(t, "hello\n", string(out))

// Check that the agent presents a key with cert and a bare key
// for compat with Paramiko and older versions of OpenSSH.
keys, err := agentClient.List()
require.NoError(t, err)
require.Len(t, keys, 2)
})
}
}
Loading