Skip to content

Commit

Permalink
Fix Paramiko and SSH multiplexer agent support (#44672)
Browse files Browse the repository at this point in the history
  • Loading branch information
strideynet authored Jul 26, 2024
1 parent 7753c1a commit 89a4180
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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)
})
}
}

0 comments on commit 89a4180

Please sign in to comment.