Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   How to interactively sending the username/password to login using ssh (http://www.velocityreviews.com/forums/t905092-how-to-interactively-sending-the-username-password-to-login-using-ssh.html)

cyrusgreats@gmail.com 10-25-2007 11:11 PM

How to interactively sending the username/password to login using ssh
 
Hi ,
I'm trying to interactively sending the username/password to login and
then send CLI commands usinf ssh, this is the only way I can access
the device, and then sending the commands when logged in, I used the
following but it seems does not pass the password, I'm sure one of you
guyus out there have an idea. Thanks in advance..


#!/usr/bin/perl

use IPC::Session;

# open ssh session to your applinace
# -- set timeout of 30 seconds for all send() calls
my $mybox = "10.0.42.111";
my $session = new IPC::Session("ssh -l usrname $mybox",30);

# use like 'expect':
print $session->send("passwd");


Here I see the Password prompt but I can't pass password ..
cheers


all mail refused 10-26-2007 12:05 AM

Re: How to interactively sending the username/password to login using ssh
 
On 2007-10-25, cyrusgreats@gmail.com <cyrusgreats@gmail.com> wrote:

> I'm trying to interactively sending the username/password to login and


passwordless logins are in the SSH docs and FAQ
http://www.snailbook.com/faq/

"expect" deals with terminal input if you really need
to provide a password that way. Various CPAN modules
involve it.
http://search.cpan.org/search?query=expect&mode=module

--
Elvis Notargiacomo master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/

Josef Moellers 10-26-2007 06:57 AM

Re: How to interactively sending the username/password to login usingssh
 
cyrusgreats@gmail.com wrote:
> Hi ,
> I'm trying to interactively sending the username/password to login and
> then send CLI commands usinf ssh, this is the only way I can access
> the device, and then sending the commands when logged in, I used the
> following but it seems does not pass the password, I'm sure one of you
> guyus out there have an idea. Thanks in advance..
>
>
> #!/usr/bin/perl
>
> use IPC::Session;
>
> # open ssh session to your applinace
> # -- set timeout of 30 seconds for all send() calls
> my $mybox = "10.0.42.111";
> my $session = new IPC::Session("ssh -l usrname $mybox",30);
>
> # use like 'expect':
> print $session->send("passwd");
>
>
> Here I see the Password prompt but I can't pass password ..
> cheers
>


I don't see anything about ttys in IPC::Session's pod. Therefore I
assume that it just spawns off an ssh with a pipe opened between the
script and the ssh (I don't have it installed, so I can't check, but you
can check using some system call trace command, e.g. strace. Beware that
you must tell strace to follow subprocesses!). For some (security?)
reasons, on Linux ssh will open /dev/tty to obtain the password, so you
can't send it through the pipe.

It would be better, indeed, to use the Expect module to handle this. On
Linux, Expect will communicate with the subprocess through a pseudo tty,
which is set up as the subprocess' controlling tty and, as such, will be
accessable through /dev/tty.

Josef
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


cyrusgreats@gmail.com 10-26-2007 04:08 PM

Re: How to interactively sending the username/password to login using ssh
 
On Oct 25, 5:05 pm, all mail refused <elvis-85...@notatla.org.uk>
wrote:
> On 2007-10-25, cyrusgre...@gmail.com <cyrusgre...@gmail.com> wrote:
>
> > I'm trying to interactively sending the username/password to login and

>
> passwordless logins are in the SSH docs and FAQ
> http://www.snailbook.com/faq/
>
> "expect" deals with terminal input if you really need
> to provide a password that way. Various CPAN modules
> involve it.
> http://search.cpan.org/search?query=expect&mode=module
>
> --
> Elvis Notargiacomo master AT barefaced DOT cheekhttp://www.notatla.org.uk/goen/


Thanks to you all I got it now.


praveen kandala 10-27-2007 02:13 AM

Re: How to interactively sending the username/password to login using ssh
 
On Oct 26, 9:08 am, cyrusgre...@gmail.com wrote:
> On Oct 25, 5:05 pm, all mail refused <elvis-85...@notatla.org.uk>
> wrote:
>
> > On 2007-10-25, cyrusgre...@gmail.com <cyrusgre...@gmail.com> wrote:

>
> > > I'm trying to interactively sending the username/password to login and

>
> > passwordless logins are in the SSH docs and FAQ
> > http://www.snailbook.com/faq/

>
> > "expect" deals with terminal input if you really need
> > to provide a password that way. Various CPAN modules
> > involve it.
> > http://search.cpan.org/search?query=expect&mode=module

>
> > --
> > Elvis Notargiacomo master AT barefaced DOT cheekhttp://www.notatla.org.uk/goen/

>
> Thanks to you all I got it now.


Why not use Net::SSH::Perl module?

Praveen Kandala



All times are GMT. The time now is 12:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57