winrm
winrm copied to clipboard
我使用这段代码 报panic: http response error: 401 - invalid content type 账号密码 都是正确的
func main() { endpoint := winrm.NewEndpoint("host", 5985, false, false, nil, nil, nil, 0)
params := winrm.DefaultParameters
params.TransportDecorator = func() winrm.Transporter { return &winrm.ClientNTLM{} }
client, err := winrm.NewClientWithParameters(endpoint, "test", "test", params)
if err != nil {
log.Fatal(err)
}
t, err := client.RunWithInput("ipconfig", os.Stdout, os.Stderr, os.Stdin)
if err != nil {
panic(err)
}
fmt.Println(t)
}
https://learn.microsoft.com/zh-cn/windows/win32/winrm/authentication-for-remote-connections
或者用户处于管理员组 administrators
有没有解决?
有没有解决?
并没有解决
https://learn.microsoft.com/zh-cn/windows/win32/winrm/authentication-for-remote-connections
或者用户处于管理员组 administrators
我这边使用的确实是adminstrator 管理员 但是还是报401
@devops-fj
想来是winrm没有配置好:
https://github.com/StefanScherer/packer-windows/blob/main/scripts/enable-winrm.ps1
It's probably because the server requires NTLM authentication - I have a PR in to implement this in this repo but this seems to be not very active
you could use https://github.com/CalypsoSys/bobwinrm
see https://github.com/CalypsoSys/bobwinrmntlm for usage