Skip to content

Commit

Permalink
feat: 设置 ssh session 的最大会话
Browse files Browse the repository at this point in the history
perf: update dep
  • Loading branch information
LeeEirc committed Jul 5, 2024
1 parent d1e55ca commit 8217ce7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ require (
)

replace (
github.com/gliderlabs/ssh => github.com/jumpserver-dev/ssh v0.1.2-0.20240209035326-4f0f6365ccae
github.com/gliderlabs/ssh => github.com/jumpserver-dev/ssh v0.1.2-0.20240523042749-9bd9e7a5793e
golang.org/x/crypto => github.com/jumpserver-dev/crypto v0.0.0-20240209025851-4b55dc4c3463
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jumpserver-dev/crypto v0.0.0-20240209025851-4b55dc4c3463 h1:ZQTX/4gO/G8SFtzn9K8M2mac83TSIyEHX9/2bnBKf1Y=
github.com/jumpserver-dev/crypto v0.0.0-20240209025851-4b55dc4c3463/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
github.com/jumpserver-dev/ssh v0.1.2-0.20240209035326-4f0f6365ccae h1:zND4fMpJoOf90TILA9CY9KTub+YLK+pdiG6LM/+9UBo=
github.com/jumpserver-dev/ssh v0.1.2-0.20240209035326-4f0f6365ccae/go.mod h1:KdoSNwfOgcFXlcr2OQ34eeKfIl7K8l6cAQ6twkYaLcU=
github.com/jumpserver-dev/ssh v0.1.2-0.20240523042749-9bd9e7a5793e h1:AmskLnxDyU079ICOeJyHOZ06nD7onemw8Q+usJM4S/c=
github.com/jumpserver-dev/ssh v0.1.2-0.20240523042749-9bd9e7a5793e/go.mod h1:KdoSNwfOgcFXlcr2OQ34eeKfIl7K8l6cAQ6twkYaLcU=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type Config struct {
// 仅控制是否缓存 sftp 的 token 连接
ConnectionTokenReusable bool `mapstructure:"CONNECTION_TOKEN_REUSABLE"`

SshMaxSessions int `mapstructure:"SSH_MAX_SESSIONS"`

RootPath string
DataFolderPath string
LogDirPath string
Expand Down
1 change: 1 addition & 0 deletions pkg/sshd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func NewSSHServer(jmsService *service.JMService) *Server {
AuthLogCallback: auth.SSHAuthLogCallback,
NextAuthMethodsHandler: func(ctx ssh.Context) []string { return []string{nextAuthMethod} },
HostSigners: []ssh.Signer{singer},
MaxSessions: int32(cf.SshMaxSessions),
ServerConfigCallback: func(ctx ssh.Context) *gossh.ServerConfig {
cfg := gossh.Config{MACs: supportedMACs, KeyExchanges: supportedKexAlgos}
return &gossh.ServerConfig{Config: cfg}
Expand Down

0 comments on commit 8217ce7

Please sign in to comment.