Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-02
5
Medium Priority
?
308 Views
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!!!
0
Comment
Question by:ericmhhui
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:bobgunzel
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.
0
 
LVL 1

Author Comment

by:ericmhhui
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.

Thanks!
0
 
LVL 2

Accepted Solution

by:
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):
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

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:
/home/<your_directory>/.ssh/authorized_keys

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!
A
0
 
LVL 1

Author Comment

by:ericmhhui
ID: 12006246
Hi

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??

Thanks!!
0
 
LVL 2

Expert Comment

by:stanford_16
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).

Cheers,
A
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

927 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