Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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
share|improve this answer
    
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 2 '10 at 8:22
    
You don't have to but then you have the problem of having to enter the password. –  John Gardeniers Apr 2 '10 at 8:35
    
I would like a way to automate entering the password. I don't mind storing the user/pass in the batch script. –  ripper234 Apr 2 '10 at 10:47
    
@ripper234, see the edit to my answer. –  John Gardeniers Apr 2 '10 at 22:26
    
Thanks, looks better –  ripper234 Apr 3 '10 at 10:34
add comment

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/

share|improve this answer
    
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 2 '10 at 8:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.