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

x
?
Solved

SSH to Linux from windows in Perl

Posted on 2009-05-10
4
Medium Priority
?
1,734 Views
Last Modified: 2012-05-06
I need to SSH to a linux box, from a windows box, and run some interactive commands to do an installation. And I have to user perl to accomplish this.

So I have run a perl script on a windows box, that will then ssh to the linux box and run commands one after the other interactively... I will have to answer in yes/no or select from 1,2,3 etc.

Is there a way to do this? I am not sure if I have provided enough information but I can answer any questions if someone has suggestions.

Thanks.
0
Comment
Question by:pavanbh
4 Comments
 
LVL 28

Accepted Solution

by:
FishMonger earned 672 total points
ID: 24348751
0
 
LVL 8

Assisted Solution

by:thetmanvn
thetmanvn earned 664 total points
ID: 24348892
Very details example using perl ssh to execute shell remotely via ssh

http://www.example-code.com/perl/ssh_exec.asp

More sample code:
http://www.example-code.com/perl/ssh_remote_command.asp
http://www.example-code.com/perl/ssh_tunnel.asp

Hope this help
0
 
LVL 2

Assisted Solution

by:jccs0519
jccs0519 earned 664 total points
ID: 24357365
If you just need Perl example or module the other comments should work for you.

If you're looking for an environment to do this on a Windows box, then you'll need to install Cygwin, there might be other solution but Cygwin works for me.  I did the same thing before using this app.

Cygwin is basically a bunch of Unix utilities that'll work on Windows command prompt.  Once installed, it'll popup like a Windows command prompt, except you can use a lot of unix utilities like ls, ssh/scp, bash scripts.  When you install you can choose what package or utilities you want to include.  I've even ran X-windows on top of Cygwin where I can remotely export X-Windows tools from a remote server like Sun Solaris admin tools.  I also has setup perl scripts to access mysql DB using cygwin before.

Anyway, in  your case, you'll need perl and ssh package.  Once install, setup ssh keys where you can access linux server without password.  ssh-keygen -t rsa, copy key to linux .ssh/authorized_keys, ensure 755 in user login, but 600 in .ssh directory.  Then you can write your perl or shell script to access the linux server.  You can remotely exec commands via ssh (ie. $ ssh linuxbox ls -l).

Hope that helps
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

916 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