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

Key based authentication doesn't work immediately after a machine reboot/restart #727

Closed
krombel opened this issue May 19, 2017 · 8 comments
Assignees
Milestone

Comments

@krombel
Copy link

krombel commented May 19, 2017

"OpenSSH for Windows" version
OpenSSH_7.5p1, OpenSSL 1.0.2d 9 Jul 2015

Server OperatingSystem
Windows Server 2012 R2 Standard

Client OperatingSystem
SUSE Linux Enterprise Server 12 SP2

What is failing
Login with public key authentication (used inside a script) not possible until a user on the machine logs on.

Expected output
I can log in every time with the public key - not just after a user has logged in once.

Actual output
After the machine reboots it is just possible to use password-based authentication. This changes after a login on the device is done once. This can be via ssh or on the machine directly.

@manojampalam
Copy link
Contributor

Did you mean that public key is not working until a user (any user) is logged in on the target? If so, is the logon an interactive logon?

Can you add more details on how exactly to reproduce this?

@krombel
Copy link
Author

krombel commented May 19, 2017

Did you mean that public key is not working until a user (any user) is logged in on the target? If so, is the logon an interactive logon?

Yes and yes.

Can you add more details on how exactly to reproduce this?

For me it is enough to reboot my machine. Then the first login via ssh requires a user and a password and all preceeding login's can be also done with public key authentication.
It is also possible to login on screen. Then I can use public keys as well.

@manojampalam
Copy link
Contributor

@krombel thanks. I was able to repro this. LsaLogonUser is failing in ssh-agent. I'll see what can be done for May-End drop.

@manojampalam manojampalam changed the title Unable to login via Public Key until a user logs in Unable to login via Public Key until a user logs in interactively on the target. May 21, 2017
@manojampalam manojampalam self-assigned this May 21, 2017
@manojampalam manojampalam modified the milestones: June-End, May-End, June-Mid Jun 2, 2017
@bingbing8 bingbing8 modified the milestones: June-End, June-Mid Jun 15, 2017
@bingbing8 bingbing8 modified the milestones: July-Mid, June-End Jun 30, 2017
@bingbing8 bingbing8 modified the milestones: Beta, July-Mid Jul 17, 2017
@rgl
Copy link

rgl commented Jul 22, 2017

I'm trying to use Win32-OpenSSH as a SSH server in Vagrant, but this issue makes the whole experience quite odd, because one has to manually login at the machine before vagrant can connect. Can this issue be moved up to the July-Mid milestone? :-)

@jake-at-work
Copy link

I am experiencing the same issue with AWS images I am building. I am able to get the key authentication to work only after interactive login, WinRm authentication, or password based ssh login. In fact, any of those authentication modes can be just an attempt with the wrong password and suddenly the key base authentication starts working. I have scripted a "knock" by simply trying ssh password authentication with a bogus password. It is not ideal but it works for now.

@manojampalam
Copy link
Contributor

Apologies for the delay as we were hung up with penetration testing. Will look into this for Aug-Mid drop.

@marcosnils
Copy link

@pivotal-jbarrett I use autologon (https://docs.microsoft.com/en-us/sysinternals/downloads/autologon) in AWS instances so the machine automatically logins at boot and then I can ssh into it. I guess it's similar to your script with the exception that autologon encrypts the password in the registry

@manojampalam
Copy link
Contributor

manojampalam commented Aug 16, 2017

I have debugged the internals of this issue (specifically lsass), and see that this is stemming from msv1_0.dll. From what I know, this should only impact workgroup accounts. Let me know if domain accounts are impacted too.

I'm adding a workaround in ssh-agent for now while I discuss this with security team.

@manojampalam manojampalam changed the title Unable to login via Public Key until a user logs in interactively on the target. Key based authentication doesn't work immediately after a machine reboot/restart Aug 16, 2017
manojampalam added a commit to PowerShell/openssh-portable that referenced this issue Aug 17, 2017
Issue is within msv1_0.dll (NTLM SSP provider). Working around by doing a fake login that populates internal state within msv1_0.dll so further S4U logons work as expected.
PowerShell/Win32-OpenSSH#727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants