diff --git a/server/common/term/ssh.go b/server/common/term/ssh.go index f62353d30..3e2fa9030 100644 --- a/server/common/term/ssh.go +++ b/server/common/term/ssh.go @@ -5,11 +5,21 @@ import ( "net" "time" + "next-terminal/server/log" + "golang.org/x/crypto/ssh" "golang.org/x/net/proxy" ) func NewSshClient(ip string, port int, username, password, privateKey, passphrase string) (*ssh.Client, error) { + log.Debug("NewSshClient", + log.String("ip", ip), + log.Int("port", port), + log.String("username", username), + log.Bool("hasPassword", password != "" && password != "-"), + log.Bool("hasPrivateKey", privateKey != "" && privateKey != "-"), + log.Bool("hasPassphrase", passphrase != "" && passphrase != "-")) + var authMethod ssh.AuthMethod if username == "-" || username == "" { username = "root" @@ -39,8 +49,10 @@ func NewSshClient(ip string, port int, username, password, privateKey, passphras } } authMethod = ssh.PublicKeys(key) + log.Debug("NewSshClient using public key auth") } else { authMethod = ssh.Password(password) + log.Debug("NewSshClient using password auth") } config := &ssh.ClientConfig{ diff --git a/server/service/gateway.go b/server/service/gateway.go index 129d8954f..adbc0800c 100644 --- a/server/service/gateway.go +++ b/server/service/gateway.go @@ -36,6 +36,17 @@ func (r gatewayService) GetGatewayById(accessGatewayId string) (g *gateway.Gatew func (r gatewayService) loadSshGateway(m *model.SshGateway) (g *gateway.Gateway, err error) { r.DisconnectById(m.ID) + log.Debug("loadSshGateway", + log.String("id", m.ID), + log.String("name", m.Name), + log.String("configMode", m.ConfigMode), + log.String("ip", m.IP), + log.Int("port", m.Port), + log.String("accountType", m.AccountType), + log.String("username", m.Username), + log.Bool("hasPassword", m.Password != ""), + log.Bool("hasPrivateKey", m.PrivateKey != "")) + // 根据配置模式获取连接信息 switch m.ConfigMode { case "direct": @@ -52,6 +63,10 @@ func (r gatewayService) loadSshGateway(m *model.SshGateway) (g *gateway.Gateway, m.Password = credential.Password m.PrivateKey = credential.PrivateKey m.Passphrase = credential.Passphrase + log.Debug("loadSshGateway from credential", + log.String("username", m.Username), + log.Bool("hasPassword", m.Password != ""), + log.Bool("hasPrivateKey", m.PrivateKey != "")) g = gateway.GlobalGatewayManager.AddFromSshGateway(m) } case "asset": @@ -67,6 +82,12 @@ func (r gatewayService) loadSshGateway(m *model.SshGateway) (g *gateway.Gateway, m.Password = asset.Password m.PrivateKey = asset.PrivateKey m.Passphrase = asset.Passphrase + log.Debug("loadSshGateway from asset", + log.String("ip", m.IP), + log.Int("port", m.Port), + log.String("username", m.Username), + log.Bool("hasPassword", m.Password != ""), + log.Bool("hasPrivateKey", m.PrivateKey != "")) g = gateway.GlobalGatewayManager.AddFromSshGateway(m) } default: diff --git a/web/src/pages/assets/AssetPost.tsx b/web/src/pages/assets/AssetPost.tsx index 321cd6eeb..966d378c5 100644 --- a/web/src/pages/assets/AssetPost.tsx +++ b/web/src/pages/assets/AssetPost.tsx @@ -333,12 +333,6 @@ const AssetsPost = function ({assetId, groupId, copy, onClose}: AssetsInfoProps) showSearch rules={[{required: true}]} debounceTime={0} - convertValue={(value: any) => { - if (value && value !== '-') { - return { value, label: value }; - } - return undefined; - }} /> ); } else if (gatewayType === 'agent') { @@ -352,12 +346,6 @@ const AssetsPost = function ({assetId, groupId, copy, onClose}: AssetsInfoProps) showSearch rules={[{required: true}]} debounceTime={0} - convertValue={(value: any) => { - if (value && value !== '-') { - return { value, label: value }; - } - return undefined; - }} /> ); } else if (gatewayType === 'group') { @@ -370,12 +358,6 @@ const AssetsPost = function ({assetId, groupId, copy, onClose}: AssetsInfoProps) params={{gatewayType}} showSearch rules={[{required: true}]} - convertValue={(value: any) => { - if (value && value !== '-') { - return { value, label: value }; - } - return undefined; - }} /> ); }