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

Posted on 2004-09-02
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

Comment Utility
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

Comment Utility
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 50 total points
Comment Utility
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

Comment Utility

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

Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now