![]() |
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 |
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/ |
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 |
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. |
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.