Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Community > The Lounge > Computers & IT



Reply
 
LinkBack Thread Tools
Old October 27th, 2011, 11:35 PM   #1 (permalink)
Frank Burns Eats Worms!
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: Evo Root Forum, Lounge, Forum Games.
Posts: 3,280
 
Device(s): Evo 4G - CleanRom 2.0 (April '12)
Thanks: 1,761
Thanked 1,122 Times in 785 Posts
Send a message via AIM to 9to5cynic
Default Perl & SSH

*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.
/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!

9to5cynic is online now  
Last edited by 9to5cynic; October 30th, 2011 at 10:32 PM. Reason: code clarity.
Reply With Quote
Sponsors
Old October 29th, 2011, 08:52 PM   #2 (permalink)
Antidisestablishmentarian
 
johnlgalt's Avatar
 
Join Date: Oct 2009
Location: 3rd Rock
Posts: 8,431
 
Device(s): Motorola® DROID® BIONIC®
Thanks: 1,836
Thanked 1,610 Times in 1,154 Posts
Send a message via ICQ to johnlgalt Send a message via MSN to johnlgalt Send a message via Yahoo to johnlgalt Send a message via Skype™ to johnlgalt johnlgalt@gmail.com
Default

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....
__________________

Files for the Motorola® DROID® BIONIC®:
Motorola USB drivers v5.5.0- 32bit | Motorola USB drivers v5.5.0- 64bit | Motorola RSD Lite v5.7
johnlgalt is online now  
Reply With Quote
Old October 29th, 2011, 11:08 PM   #3 (permalink)
Frank Burns Eats Worms!
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: Evo Root Forum, Lounge, Forum Games.
Posts: 3,280
 
Device(s): Evo 4G - CleanRom 2.0 (April '12)
Thanks: 1,761
Thanked 1,122 Times in 785 Posts
Send a message via AIM to 9to5cynic
Default

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?
9to5cynic is online now  
Reply With Quote
Old October 29th, 2011, 11:15 PM   #4 (permalink)
Antidisestablishmentarian
 
johnlgalt's Avatar
 
Join Date: Oct 2009
Location: 3rd Rock
Posts: 8,431
 
Device(s): Motorola® DROID® BIONIC®
Thanks: 1,836
Thanked 1,610 Times in 1,154 Posts
Send a message via ICQ to johnlgalt Send a message via MSN to johnlgalt Send a message via Yahoo to johnlgalt Send a message via Skype™ to johnlgalt johnlgalt@gmail.com
Default

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
johnlgalt is online now  
Reply With Quote
The Following User Says Thank You to johnlgalt For This Useful Post:
9to5cynic (October 29th, 2011)
Old October 29th, 2011, 11:19 PM   #5 (permalink)
Frank Burns Eats Worms!
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: Evo Root Forum, Lounge, Forum Games.
Posts: 3,280
 
Device(s): Evo 4G - CleanRom 2.0 (April '12)
Thanks: 1,761
Thanked 1,122 Times in 785 Posts
Send a message via AIM to 9to5cynic
Default

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
9to5cynic is online now  
Reply With Quote
Old October 29th, 2011, 11:27 PM   #6 (permalink)
Frank Burns Eats Worms!
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: Evo Root Forum, Lounge, Forum Games.
Posts: 3,280
 
Device(s): Evo 4G - CleanRom 2.0 (April '12)
Thanks: 1,761
Thanked 1,122 Times in 785 Posts
Send a message via AIM to 9to5cynic
Default

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 “yes”,
             then a client started with -f will wait for all remote port for‐
             wards to be successfully established before placing itself in the
             background.
I'm googleing (googling?) an example, it keeps telling me that in order to fork into the background I need a command to run first... but I'm unaware how to set that command besides from how I have it in the post above.

Thanks johnlgalt for the assistance!

Well, I thought BatchMode was what I needed (it suppresses prompts), but that does nothing for me if I can't get SSH w/o passwords to work cross platform...
9to5cynic is online now  
Last edited by 9to5cynic; October 30th, 2011 at 12:05 AM. Reason: BatchMode, not a superhero.
Reply With Quote
Old October 31st, 2011, 08:38 PM   #7 (permalink)
Antidisestablishmentarian
 
johnlgalt's Avatar
 
Join Date: Oct 2009
Location: 3rd Rock
Posts: 8,431
 
Device(s): Motorola® DROID® BIONIC®
Thanks: 1,836
Thanked 1,610 Times in 1,154 Posts
Send a message via ICQ to johnlgalt Send a message via MSN to johnlgalt Send a message via Yahoo to johnlgalt Send a message via Skype™ to johnlgalt johnlgalt@gmail.com
Default

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....
johnlgalt is online now  
Reply With Quote
Old October 31st, 2011, 09:21 PM   #8 (permalink)
Frank Burns Eats Worms!
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: Evo Root Forum, Lounge, Forum Games.
Posts: 3,280
 
Device(s): Evo 4G - CleanRom 2.0 (April '12)
Thanks: 1,761
Thanked 1,122 Times in 785 Posts
Send a message via AIM to 9to5cynic
Default

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!
9to5cynic is online now  
Reply With Quote
Old November 1st, 2011, 03:18 PM   #9 (permalink)
Antidisestablishmentarian
 
johnlgalt's Avatar
 
Join Date: Oct 2009
Location: 3rd Rock
Posts: 8,431
 
Device(s): Motorola® DROID® BIONIC®
Thanks: 1,836
Thanked 1,610 Times in 1,154 Posts
Send a message via ICQ to johnlgalt Send a message via MSN to johnlgalt Send a message via Yahoo to johnlgalt Send a message via Skype™ to johnlgalt johnlgalt@gmail.com
Default

Ahhh, even better. lol
johnlgalt is online now  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Community > The Lounge > Computers & IT User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 03:27 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo