SDK远程登录ECI实例 本文为您介绍如何使用SDK远程登录ECI实例。 使用ECI SDK提供的示例代码,执行execCommand命令。 注入AK/SK环境变量 SDK调用依赖用户AK/SK,请从官网获取。 shell var ( accessKey "" secretKey "" baseDomain " ) func init() { accessKey os.Getenv("CTAPIAK") secretKey os.Getenv("CTAPISK") domain : os.Getenv("CTAPIECIDOMAIN") if domain ! "" { baseDomain domain } } 初始化客户端 shell func main() { config : &config.OpenapiConfig{ AccessKey: accessKey, SecretKey: secretKey, } options : []eci.Option{ eci.WithClientConfig(config), eci.WithClientOption(cli.WithTLSConfig(&tls.Config{ InsecureSkipVerify: true, })), } client, err : eci.NewClientSet(baseDomain, options...) if err ! nil { fmt.Println(err) return } ctx : context.Background() req : &containergroup.ExecCommandRequest{ // Fill in the request parameters ContainerGroupId: "ecivtyz7dxommh6wna4", ContainerName: "container1", Command: []string{"/bin/sh"}, TTY: true, Stdin: true, Sync: false, RegionId: "bb9fdb42056f11eda1610242ac110002", } resp, raw, err : client.ContainerGroup().ExecCommand(ctx, req) if err ! nil { fmt.Println(err) return } fmt.Printf("raw: %vnresp: %vn", string(raw.Body()), resp) 连接WebSocket shell if err : execContainerWebsocket(resp.RequestId, resp.WebSocketUri); err ! nil { fmt.Println(err) } }