Score:0

Powershell ssh connection from linux to Domain Controller is extremely slow

cn flag

I have PHP application to create user accounts in our Windows Active Directory. This application is running on Apache and Debian 11. I have LDAP only (because of some apps which are not supporting LDAPS), so I'm unable to set password directly from PHP. I'm trying to achieve this using powershell via ssh. I have installed latest versions 7.2 on both linux and domain controller. On DC I added OpenSSH server and turned firewall off. I've added the linux computer to trustedHosts on DC.

I'm able to connect to DC from remote computer via putty and it runs smoothly. When I use [email protected] from linux server, it runs well too, however when I run something like this from linux server

Invoke-Command -ComputerName 192.168.2.11 -Credential $creds -Authentication Negotiate -ScriptBlock {Get-Process}

where $creds contains something like domain\lastname.firstname (also tried [email protected]) and password, it takes from 2 to 5 minutes to execute this command. When I try Enter-PSSession and connect to DC, every single command take several minutes to execute, for example if I run Get-Date, it take another 2-5 minutes to execute. Even when I just hit enter without command, I can continue with the terminal again after 2-5 minutes.

I've tried it on Debian9,Debian11, Windows Server 2019 and 2022.

Mathias R. Jessen avatar
us flag
Does it make a difference if you add `-SessionOption (New-PSSessionOption -NoMachineProfile)` to either `Invoke-Command` or `Enter-PSSession`?
cn flag
Hi Mathias, thanks for comment. There is no -NoMachineProfile switch for New-PSSessionOption on linux :( I have a "solution" already, I will create an answer.
Score:0
cn flag

I already solved it. There was no problem at all, at least for the task I want to achieve. I used putty to connect to Linux VM and then from there I tried to run these Powershell remote commands to connect to DC and it was extremely slow, as I described, but when I connected to Windows server with ssh command (outside of powershell), everything runs well, only the powershell commands were slow.

When I use VirtualBox console to connect to this Linux VM and not putty(ssh), everything is running smoothly. I need to run the powershell from PHP, so there is not needed to connect via ssh first, I used it just for testing and it cost me 2 days of labouring. I'm perfect fine with this soludion. Hope this helps someone.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.