Solved

SSH to Linux from windows in Perl

Posted on 2009-05-10
4
1,687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 28

Accepted Solution

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

Assisted Solution

by:thetmanvn
thetmanvn earned 166 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 166 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

630 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