Linux to Windows powershell remoting (Kali 2019.4)

It is possible to do powershell remoting from Linux to Windows but I didn’t find the process especially obvious. After spelunking through a bunch of GitHub discussions I did make it all work. This is a short summary of the solutions that mattered to me. I assume this will become out-of-date quickly but if you’re lucky it might save you some time.

The scenario is where you might run the following on Windows, having ensured the target host is trusted.

PS > Enter-PSSession xxx.xxx.xxx.xxx -Credential DOMAIN\username

When working, both Windows and Linux will prompt for the corresponding password.

Problem: No powershell on Kali

Solution:

apt install powershell

Run as pwsh

Problem: Error message about no WSMan client library

This parameter set requires WSMan, and no supported WSMan client library was found.
WSMan is either not installed or unavailable for this system.

Solution: Chances are the libmi.so installed by powershell is requesting libssl-1.0.0 and libcrypto-1.0.0 specifically but only 1.0.2 is installed for each. Verify this:

# ldd /opt/microsoft/powershell/6/libmi.so
...
        libssl.so.1.0.0 => not found
        libcrypto.so.1.0.0 => not found
...

Then add symlinks. Yes this is dodgy but who’s getting precious about the sanctity of their Kali installation?

# cd /usr/lib/x86_64-linux-gnu
# ln -s libssl.so.1.0.2 libssl.so.1.0.0
# ln -s libcrypto.so.1.0.2 libcrypto.so.1.0.0

Credit: https://github.com/PowerShell/PowerShell/issues/5561#issuecomment-368496307

Problem: Error message about unspecified GSS failure

Enter-PSSession : Connecting to remote server xxx.xxx.xxx.xxx failed with the
following error message : acquiring creds with username only failed Unspecified
GSS failure.  Minor code may provide more information SPNEGO cannot find mechanisms
to negotiate For more information, see the about_Remote_Troubleshooting Help topic. 

Solution:

apt install gss-ntlmssp

Credit: https://github.com/PowerShell/PowerShell-Docker/issues/124#issuecomment-462177207

Problem: Error message about access denied connecting with NTLM

Enter-PSSession : MI_RESULT_ACCESS_DENIED

Solution: Make sure to use -Authentication Negotiate even if this isn’t necessary when remoting from a Windows client.

Credit: https://github.com/PowerShell/PowerShell/issues/6647#issuecomment-472261499