2

What's the easiest way to execute a single command on a Mac from a remote Windows machine, via batch?

I would like something that works without a preset configuration (like SSH credentials) on either machines, as I need to apply this on several Win/Mac pairs (yes, I know it's less secure, but it's not relevant to my needs).

The macs all have a common user/password (in fact, they are on the same domain), and I want to automate this as painlessly as possible.

ripper234
  • 5,890
  • 9
  • 41
  • 49

2 Answers2

3

Anything like this, whether it's to a Mac or a Linux machine I use WinSCP, as it has good scripting support and is very easy to use. Just set up public keys for SSH to eliminate the password prompt.

Edit

Here's a batch file using PuTTY if you don't mind the password issue.

@echo off
echo command1; command2; commandn; exit>tmp_file
putty -ssh user@taget_machine -pw password -m tmp_file
John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
0

I suppose on the windows server you could use putty/plink to connect to the mac via SSH (assuming that ssh is open and running).

First use putty to create a shared key on the windows server and you'll put that on the mac... probably authorized_keys file. Don't set a password on the key.

Then, you could use plink to login and run a command using that key.

Check out: http://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter7.html#plink-usage-batch "7.2.2 Using Plink for automated connections"

Putty is available here: http://www.chiark.greenend.org.uk/~sgtatham/putty/

Imo
  • 841
  • 5
  • 7
  • I would like something that doesn't force me to setup SSH public keys, because i need to set them up from/to multiple computers. – ripper234 Apr 02 '10 at 08:23