Description
"OpenSSH for Windows" version
0.0.24.0
Server OperatingSystem
Windows 7 Professional (64 bit)
Client OperatingSystem
Ubuntu 16.04 (or any other, does not matter here)
What is failing
The way sshd currently sets up the login processes prevents me from saving there any Active Directory credential (Kerberos ticket) obtained using either the CMDKEY or NET USE commands. This prevents me accessing any domain-controlled network shares in an ssh session to a local user account.
I log into a local user account cheltenham\mgk25 (the Win7 PC "cheltenham" is not joined to any Active Directory domain). When I do this from the console or via rdesktop, I can then later provide in CMD an Active Directory username and password with either CMDKEY or NET USE in order to access a file share on a NetApp SMB file server "elmer", where I have an Active Directory account AD.CL.CAM.AC.UK\mgk25. However, both the "CMDKEY /add:... /user:..." and the "NET USE ... /user:..." commands fail when I run them via OpenSSH's sshd. :-( It appears that sshd is not setting up the process environment correctly to allow me to obtain and save Active Directory Kerberos credentials.
While trying to investigate what is different between ssh and rdesktop sessions, I noticed that when I type QUERY SESSION on the console or via rdesktop, it shows that I am running in session 1 or 2 (meant for users), whereas if I log in via sshd, I run in session 0 (meant for services). I had thought that (since Windows Vista) all Windows processes associated with a logged-in user must run in sessions >0 to avoid the "shatter attack". I wonder if running in the wrong session is also related to CMDKEY not working here. Both error messages do mention a "logon session" as the reason for the failure.
Expected output
Credential needed for file share access is added successfully when I login via rdesktop to call CMDKEY, and QUERY SESSION shows that I am in an "Active" session with ID > 0:
C:\>cmdkey /add:elmer.cl.cam.ac.uk /user:mgk25@AD.CL.CAM.AC.UK /pass
Enter the password for 'mgk25@AD.CL.CAM.AC.UK` to connect to 'elmer.cl.cam.ac.uk':
CMDKEY: Credential added successfully
C:\>query session
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
console 1 Conn
>rdp-tcp#0 mgk25 2 Active rdpwd
rdp-tcp 65536 Listen
C:\>net use \\elmer.cl.cam.ac.uk\userfiles\mgk25
The command completed successfully.
From the console, it looks the same, except for the active session being 1:
C:\>query session
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
>console mgk25 1 Active
rdp-tcp 65536 Listen
Actual output
Via ssh (using either publickey or password authentication), both CMDKEY and NET USE fail and the current (">") session is shown as ID = 0 and not "Active":
C:\>cmdkey /add:elmer.cl.cam.ac.uk /user:mgk25@AD.CL.CAM.AC.UK /pass
CMDKEY: Credentials cannot be saved from this logon session.
C:\>query session
SESSIONNAME USERNAME ID STATE TYPE DEVICE
>services 0 Disc
console 1 Conn
rdp-tcp 65536 Listen
C:\>net use \\elmer.cl.cam.ac.uk\userfiles\mgk25 * /user:mgk25@AD.CL.CAM.AC.UK
Type the password for \\elmer.cl.cam.ac.uk\userfiles\mgk25:
System error 1312 has occurred.
A specified logon session does not exist. It may already have been terminated.