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

Commit92e2d6d

Browse files
committed
fix(agent/agentssh): pin random seed for RSA key generation
Change-Id: I8c7e3070324e5d558374fd6891eea9d48660e1e9Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent4732f08 commit92e2d6d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎agent/agentssh/agentssh.go‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package agentssh
33
import (
44
"bufio"
55
"context"
6-
"crypto/rand"
76
"crypto/rsa"
87
"errors"
98
"fmt"
109
"io"
10+
"math/rand"
1111
"net"
1212
"os"
1313
"os/exec"
@@ -115,11 +115,14 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
115115
// Clients' should ignore the host key when connecting.
116116
// The agent needs to authenticate with coderd to SSH,
117117
// so SSH authentication doesn't improve security.
118-
randomHostKey,err:=rsa.GenerateKey(rand.Reader,2048)
118+
119+
// Create a deterministic random source
120+
deterministicRand:=rand.New(rand.NewSource(42))
121+
coderHostKey,err:=rsa.GenerateKey(deterministicRand,2048)
119122
iferr!=nil {
120123
returnnil,err
121124
}
122-
randomSigner,err:=gossh.NewSignerFromKey(randomHostKey)
125+
coderSigner,err:=gossh.NewSignerFromKey(coderHostKey)
123126
iferr!=nil {
124127
returnnil,err
125128
}
@@ -190,7 +193,7 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
190193
slog.Error(err))
191194
},
192195
Handler:s.sessionHandler,
193-
HostSigners: []ssh.Signer{randomSigner},
196+
HostSigners: []ssh.Signer{coderSigner},
194197
LocalPortForwardingCallback:func(ctx ssh.Context,destinationHoststring,destinationPortuint32)bool {
195198
// Allow local port forwarding all!
196199
s.logger.Debug(ctx,"local port forward",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp