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

http response error: 401 - invalid content type #140

Open
NikunjPatel31 opened this issue Sep 25, 2023 · 2 comments
Open

http response error: 401 - invalid content type #140

NikunjPatel31 opened this issue Sep 25, 2023 · 2 comments

Comments

@NikunjPatel31
Copy link

endpoint := &winrm.Endpoint{Host: "Host", Port: 5985, HTTPS: false, Insecure: false, CACert: nil, Cert: nil, Key: nil, Timeout: 100}
params := winrm.Parameters{TransportDecorator: func() winrm.Transporter { return &winrm.ClientNTLM{} }}
client, err = winrm.NewClientWithParameters(endpoint, "username", "password", &params)
shell, err = client.CreateShell()

Getting error while creating shell -"http response error: 401 - invalid content type"

The device I am trying to connect has NTLM enabled.

I tried to connect using python winrm library it got connected, but when I tried to connect it using go lang it is giving error.
Python Library - pywinrm

@CalypsoSys
Copy link
Contributor

CalypsoSys commented Sep 26, 2023

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

@NikunjPatel31
Copy link
Author

Thank you @CalypsoSys for answer :-

Client
NetworkDelayms = 5000
URLPrefix = wsman
AllowUnencrypted = false
Auth
Basic = false
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = false
DefaultPorts
HTTP = 5985
HTTPS = 5986
TrustedHosts

AllowUnencrypted = false
Auth
Basic = false
Kerberos = true
Negotiate = true
Certificate = false
CredSSP = false
CbtHardeningLevel = Relaxed
DefaultPorts
HTTP = 5985
HTTPS = 5986
IPv4Filter = *
IPv6Filter = *
EnableCompatibilityHttpListener = false
EnableCompatibilityHttpsListener = false
CertificateThumbprint

This is my winrm configuration.

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

2 participants