What is the simplest way to run a script remotely on Linux server from Windows without rsh?

Posted on 2004-09-02
Medium Priority
Last Modified: 2010-05-18
Hi Experts,

     I am trying to run a script on a Linux server from windows.  I don't have rsh service available.  What's the most simple way to do this??  If possible, here's what i want:

a DOS batch file on windows that i just double click and then it will run the script on the linux server.

Thx a lot!!!
Question by:ericmhhui
  • 2
  • 2

Expert Comment

ID: 11971020
Install a service in /etc/inetd.conf,  f.i.
<name>      stream  tcp     nowait  <username>    /usr/sbin/tcpd  /bin/bash -c /sbin/<yourscript>

Assign a port/protocol in /etc/services:
<name>      <portnumber>/tcp

restart inetd: killall -HUP inetd

Now all you have to do is to make a tcp connection to that portnumber. This can be done f.i. by your browser or telnet.

Author Comment

ID: 11972626
Hi bobqunzel,

     I don't have administrator rights.  Is there some other way to do this?  All I have is ftp from the windows command prompt, telnet and ssh.  Is there a way to write a ssh script or telnet script?  I am not too famaliar with this, but I cannot use anything that requires administrative rights to setup.


Accepted Solution

stanford_16 earned 200 total points
ID: 12006176
You can absolutely write a script via ssh, assuming you have an acccount on the Linux server (doesn't have to be root, by the way).

There are two ways to do this, based upon the complexity of the script that you wish to write.  The best way is as such:

Log on to the Linux server via SSH.  This doesn't require administrative priviledges on either system, just a simple login.  Using your favorite editor, write your script.  If the script is already written, you can use FTP or SFTP to copy the file.

Let's assume that you have Putty, plink, pscp, and puttygen on the Windows system:
(You can download all of these tools here):

Assuming you need to write the script:

1.  In Putty, type the IP address or hostname of the Linux server, and select SSH.  Click on "Open"

2.  Log into the Linux server with your username and password.

3.  Type your script in your favorite editor.

Assuming you need to copy the script over from the Windows system:

1.  Start -> Run -> "cmd" <Enter>
2.  c:\> ftp <IP Address of Linux Server>  and login
3.  ftp>  put <local file>

Now that the script is on the system, we need to set up the DOS script.

There are two ways to do this; using a password, and using a key (recommended)

Once the script is in your home directory, you can use putty in a DOS batch script to execute the script like so:

First, fire up puttygen.  Create an SSH2 RSA key.  Save it somewhere that is easy for your batch script to find.
You'll notice a window at the top that says "Public key for pasting into OpenSSH".  Copy that to the linux server as this filename:

This allows you to connect to the server without a password.

Next, write your DOS batch script.  It will look like this:

@echo off
...\plink.exe --ssh -i D:\PATH\TO\SSH\KEY  root@HOST  ./my_script

This should get you started.  Good luck!

Author Comment

ID: 12006246

Is plink and puttygen separate programs from putty?

and from
...\plink.exe --ssh -i D:\PATH\TO\SSH\KEY  root@HOST  ./my_script
i am not the root account, can i do username@HOST instead??


Expert Comment

ID: 12006324
Sorry about the root, yes, you can use username@HOST.

Also, if you click on the link in my last post, you will find plink and puttygen (which are separate programs from putty).


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question