Linux – Running commands remotely through an RDP connection

command linelinuxremote desktopsshwindows

This question is a follow up of this one. I am trying to run a command through the command line on a remote machine running Windows 7 from a workstation running Debian in an SSH session on that machine. The setup is basically as follows:

debian box 1 === (SSH) ===> debian box 2 === (RDP) ===> Windows 7

I have tried running rdesktop from debian box 2:

rdesktop <Windows 7 box network address> -u username -p password -r disk:local="./TestRDP" -s "cmd.exe /K net use C: \\\\tsclient\local & C:\\test.bat & logoff"

but cmd.exe is not launched on the remote device. I have also tried to open up cmd.exe on its own:

rdesktop <Windows 7 box network address> -u username -p password -s "cmd.exe"

but the terminal is not launched upon login (rdesktop successfully connects through RDP).

I also tried using FreeRDP:

xfreerdp /u:user /p:password /app:"||cmd" /v:<Windows 7 box network address>

but this error was given upon executing cmd.exe:

RAIL exec error: execResult=RAIL_EXEC_E_NOT_IN_ALLOWLIST NtError=0x15

Reading this (dated) blog entry it is recommended that a registry key is added with the path to the binary (%windir%\System32\cmd.exe) but I cannot edit registry values on the remote machine.

This question suggests using windows remote shell and a third party rdp client to run the terminal on the remote windows machine. Are there any linux alternatives (aside from FreeRDP and rdesktop)?

Best Answer

you have to open a port on your firewall to let clients connect to it, SSH runs on port 22, so that's the port you want to forward.

If you run the KDE desktop, you might prefer krdc tuto, the KDE RDP viewer. The command line would look like this:

krdc --window --high-quality rdp:/1.2.3.4[:3389]

replace "1.2.3.4" with the host IP address, and 3389 with a different port if necessary.

Related Question