Solved

SSH to Linux from windows in Perl

Posted on 2009-05-10
4
1,597 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 168 total points
Comment Utility
0
 
LVL 8

Assisted Solution

by:thetmanvn
thetmanvn earned 166 total points
Comment Utility
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 166 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Regular Expression for URL 10 79
fix34  challenge 9 95
countClumps  challenge 10 90
firstChar challenge 13 83
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

771 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

11 Experts available now in Live!

Get 1:1 Help Now