• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Perl & SSH

9to5cynic

Android Expert
*I think this is the right place for this if not blast it off in the right direction with ;)*

Okay, here's what I'm trying to do.

I need to ssh into a windows comp (running freeSSHD), from a linux comp... all within a perl script. I had it all worked out save the ssh part.

It kicks me out for the password authentication... I've tried using private/public keys on both, and that seems to hang up somewhere. If I had to guess, I'd say it is because they are different ssh server/clients (openSSH and freeSSHD)... but I really don't know.

Also, with my very limited Internet resources, I can't download a bunch of files (anything over 1-2 MB is really pushing it ... :/ )... so I don't think I'll be able to do NET::SSH::PERL or anything like that from CPAN...

EDIT
Okay, so I was not able to install cygwin, because it is an online installer and I have lousy internet, but I did stumble upon a windows port of openssh, that was an offline installer, it is very out of date but I was able to (somehow) get the private key authentication working, so issue solved. :D
/EDIT
Any suggestions?
I've tried things like this...
Code:
$IP = "192.168.1.10";
$ssh = `ssh user@$IP`;
$x = `password`;
#
#And I've tried it with
system("password");
#and even tried it as 
$ssh = `ssh user@$IP` . `password`;
If anyone has *any* ideas what-so-ever, it'd be greatly appreciated. Thanks!
 
Can you SSH into it directly from a client without the PerL script?

Since it is you, I'm guessing that you can, it's just the PerL syntax that is kicking you right ow....
 
You mean with bash or sh? While I know very little about perl, I know less about bash/sh scripting. Am I right to assume that the script would look something like this...
Code:
$ip = "192.168.10.50";
ssh username@$ip;
password;
<windows commands>
<windows exit>
all within a loop?
 
I suppose just directly in a command line - just logging in to the daemon running on the Windows side to make sure it's actually taking the login part - as long as you can look around in the Windows login when logging in from the *nix box then that will rule out a config error on the freeSSHD
 
From terminal without scripts I can log in, it just seems to be whenever I am prompted for a password, the script ends and I'm left putting in the remaining input w/o script assistance.

Here's my latest sh script:
Code:
#!/bin/sh
#
IP="192.168.91.133"

ssh $IP -l sshuser 
`password`
`mkdir windowsDir`
#I also tried w/o the ticks, but still kicks me back out...
exit 0
 
Okay, so I'm reading over the man file for ssh, and I've stumbled upon the -f flag, which seems like it might be a useful option...

Code:
 -f      Requests ssh to go to background just before command execution.
             This is useful if ssh is going to ask for passwords or
             passphrases, but the user wants it in the background.  This
             implies -n.  The recommended way to start X11 programs at a
             remote site is with something like ssh -f host xterm.

             If the ExitOnForwardFailure configuration option is set to
 
I know there has to be a way to do this - I've seen it done in front of my very eyes.

Let me see if I can dig up the link where I saw it done....
 
Thanks, but no need. Unless you want to. I got it working by finding an offline installer for openSSH for windows. It is very outdated, but I did manage to get the private keys working (for password-less login).

Thanks though!
 
Back
Top Bottom