Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我使用这段代码 报panic: http response error: 401 - invalid content type 账号密码 都是正确的 #137

Open
devops-fj opened this issue Jul 19, 2023 · 6 comments

Comments

@devops-fj
Copy link

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)

}

@gdlxSong
Copy link

gdlxSong commented Aug 4, 2023

https://learn.microsoft.com/zh-cn/windows/win32/winrm/authentication-for-remote-connections

或者用户处于管理员组 administrators

@JieWaZi
Copy link

JieWaZi commented Aug 14, 2023

有没有解决?

@devops-fj
Copy link
Author

有没有解决?

并没有解决

@devops-fj
Copy link
Author

https://learn.microsoft.com/zh-cn/windows/win32/winrm/authentication-for-remote-connections

或者用户处于管理员组 administrators

我这边使用的确实是adminstrator 管理员 但是还是报401

@gdlxSong
Copy link

@CalypsoSys
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants