"SSH server" in Windows?

11

5

I have some command-line commands to execute on a Windows machine. The programs I need to run are only available on Windows.

Is there a way to easily to do something like I would do with SSH? Example of what I mean:

ssh username@windows-box.mycompany.com "remote command to execute"

...or do I have to Remote Desktop just to do this? (I'd like to run the commands programmatically from another computer rather than running them by hand.)

Benjamin Oakes

Posted 2010-03-31T13:38:08.320

Reputation: 2 585

So, am I correct in reading between the lines that this "other computer" is not running windows, and that this is the reason you want/need to execute these commands remotely? – SamB – 2010-04-24T15:41:58.120

@SamB: Yes, that's correct. I'm using Ubuntu on my main machine. – Benjamin Oakes – 2010-04-26T19:52:09.007

Answers

8

One approach, of course, is to actually run an SSH server on the windows box. But a more Windows-focused solution is a tool from the SysInternals folks (now part of Microsoft) called PsExec, which is designed to do exactly what you want.

Jacob Mattison

Posted 2010-03-31T13:38:08.320

Reputation: 196

2But PsExec only runs on Windows systems, right? – SamB – 2010-04-24T15:49:48.243

@SamB Yes. It's actually used to run commands with (super-)elevated privileges, including as the SYSTEM account (not only Administrator). – Matthieu – 2019-10-31T09:50:08.660

2

You need a SSH server running on windows. like http://www.kpym.com/2/kpym/index.htm

There isnt any installed by default, And I have been using this for some time. it is good

Midhat

Posted 2010-03-31T13:38:08.320

Reputation: 464

Remark, this solution does not support key authentication. – sorin – 2010-09-07T07:58:39.633

2

I've had a lot of good experience installing cygwin and its sshd port. There are wrappers which will turn it into a windows service, and you get the bash shell as an extra.

http://chinese-watercolor.com/LRP/printsrv/cygwin-sshd.html is a decent starting point, you can evaluate if it is what you want.

Edwin Buck

Posted 2010-03-31T13:38:08.320

Reputation: 231

Agreed, cygwin + ssh is nice and easy, and you get a conveniently unix-like shell and environment to run your programs from. If you like ssh, you probably already know Unix. – None – 2010-03-31T15:24:24.823

2

You can use the freesshd server from fresshd.com. It does work great, you will set-up the server in seconds :)

twk

Posted 2010-03-31T13:38:08.320

Reputation: 531

This looks as a nice solution but, the forum is down (cannot post) and it looks that it doesn't allow domain logins. – sorin – 2010-04-30T12:36:14.837

Also, this is only 'free', meaning that every time you do a SSH it will display you a login message asking you to register(buy) it, you have to wait 5+ seconds to be able to continue. – sorin – 2010-09-07T08:18:46.423

Remark, this is a slow SSH server. – sorin – 2010-09-07T08:20:11.163

1I tried freesshd - what you get is a login into a windows shell (cmd.exe?) with a fixed width that does not adapt to your terminal client, i.e. you get annoying line breaks mid-screen. Also, it's nowhere near a bash shell, so I figured, if I want a really usable ssh login into my windows box, I'll do it using cygwin, which I've done before. Granted, cygwin is a bit like an os inside the os, but it does make windows usable for a (unix) cmd line user. – Eugene Beresovsky – 2013-03-12T09:01:19.730

2

Benjamin Oakes

Posted 2010-03-31T13:38:08.320

Reputation: 2 585

0

Cygwin has a ssh server, howtogeek has a simple guide you can follow http://www.howtogeek.com/howto/41560/how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/

nwgat

Posted 2010-03-31T13:38:08.320

Reputation: 961

-1

you can install an SSH server on your Windows machines, or you can turn on Terminal services on windows (check your documentation), and then use Perl(or Python) to do a telnet to the server to execute your commands. See Net::Telnet(Perl) for examples of connecting through telnet

user31894

Posted 2010-03-31T13:38:08.320

Reputation: 2 245

1Well, it's all fine and dandy to say RTFM, but that would be easier if we could find said manual... any tips, such as the name of page and maybe an MSDN/Technet link -- especially now that it seems like MS may have finally learned the value of an URL? – SamB – 2010-04-24T15:53:52.023

Also, isn't there some registry change needed to get it let you have more than one logged-in session at the same time on anything less than Server? I doubt MS would want to make the docs for that easy to find, assuming that there are any docs for that... – SamB – 2010-04-24T20:27:15.067