Accessing Windows console remotely from Linux
Have you ever needed to execute a command or to connect to an interactive text console on a remote Windows station?
Probably several times, and usually, you had to log in using either VNC or RDP (Remote Desktop Protocol – Microsoft Terminal Services). If you’re used to SSH, you may wonder why the overhead of a complete desktop is needed just to start a few text commands.
Of course, there are free and commercial SSH servers for Windows, but one problem with them is that they have to be installed separately. Which may be too much work for a one-off task now and then. Are there any other methods of accessing a remote Window text console from your Linux station?
But hey, here comes winexe to the rescue! Below, accessing Windows CLI from Linux remotely (using a Windows domain account):
From the project’s page, “winexe remotely executes commands on WindowsNT/2000/XP/2003 systems from GNU/Linux (probably also other Unices capable to compile Samba4)“.
Some notes:
- note that winexe doesn’t offer encryption of any kind – you may want to use VPN to make sure your connection is secure,
- if your distribution doesn’t offer a packaged version of winexe (most distributions don’t), winexe homepage offers a static binary; on the other hand if you have a recent Linux distribution, the static binary will most probably not work for you – in that case, just build the tool from source,
- you can use winexe in your Linux scripts – this way, you may execute certain tasks on your Linux machines, other tasks on your Windows machines – all that as a part of one bigger task / script,
- winexe can be seen as a Linux equivalent of psexec (a similar tool available for Windows).
Useful examples:
- See the list of processes / logged in users. Useful if you want to log in via RDP but don’t want to interrupt user session. Useful in a script, to check more workstations.
winexe --system -U 'DOMAIN\Administrator%password' //192.168.10.21 "tasklist /V"
- Start cmd.exe console:
winexe --system -U 'DOMAIN\Administrator%password' //192.168.10.21 cmd.exe

Do you know if this can be used to access servers across the internet? So far ive only been able to connect to machines on my local lan, which doesnt help with remote servers. Do you know if any ports need to be opened for this to happen? What protocol does it use?
It can be used over the internet, although usernames/passwords and all data is transferred in plain, so someone on the way can easily capture it.
In short – use VPN.
…just use the integrated telnet server of any windows, thru an AD policy to start automatically and done; this guys have a nice port of openssh http://sshwindows.sourceforge.net/, but is very old and not updated…
I can execute noninteractive commands with winexe quite well but I can’t get an interactive session like in your screenshot (except on one vista box but never on an xp) no matter if I use the binary from the winexe-site or the one I built myself. Also do you have readline-support?
@ali: I don’t have readline support. I never experienced problems with running an interactive session. What are the symptoms for you, when you connect and try to start cmd.exe?
[...] allow to add component on this server. September 30, 2009 5:29 am blank3 Why not try Winexe? It grants you Windows console access from Unix-like system. September 30, 2009 7:17 am [...]
[...] not try Winexe? It grants you Windows console access from Unix-like [...]