Re: Question on input password on ssh prompt



On Sep 19, 11:44 pm, Mav <mluv...@xxxxxxxxx> wrote:
On Sep 19, 10:25 am, Mav <mluv...@xxxxxxxxx> wrote:



On Sep 17, 5:02 pm, Ben Morrow <b...@xxxxxxxxxxxx> wrote:

Quoth Mav <mluv...@xxxxxxxxx>:

On Sep 17, 10:23 am, Ben Morrow <b...@xxxxxxxxxxxx> wrote:
Quoth "J. Gleixner" <glex_no-s...@xxxxxxxxxxxxxxxxxxxxx>:

Mav wrote:

In fact, The actual script I am working actually first generates the
public key on the PC side(for that PC), then append the public key
into linux (.ssh/authorized_key) entry thru ssh command. So next time,
if the PC invokes a command from the PC to linux side thru ssh, it
will not prompt the password. Any suggestion?

You have to authenticate to have SSH work. That authentication
can be public key or by providing the password. You might want
to look at the Expect module, to automate the initial authentication
with the password. Probably the best route is if the ssh keys don't
exist, then to have the script prompt for the password when it
runs, and have it pass it to SSH, using Expect.

No, that won't work, as Expect requires ptys, which WinXP doesn't have.
I think the OP's best way forward is to try Net::SSH::W32Perl, which can
log in with a password.

I looks into the Net::SSH::W32Perl, when I tried to use that I got the
error:

use Net::SSH::W32Perl;
my $ssh = new Net::SSH::W32Perl($host, protocol => 2, debug=>1);

The getpwuid function is unimplemented at C:/Perl/site/lib/Net/SSH/
Perl.pm line
110.

line 110 on Perl.pm regarding to environment variable $HOME on PC. Do
you encounter the same problem? That means that I have to set the
$HOME in my script?

Err... yes, looks like it. I always have %HOME% set to my profile
directory anyway under Win32... I guess this could be reported as a bug
in N:S:W32Perl or N:S:Perl: the correct answer would be to use
File::HomeDir. You should probably put

use File::HomeDir;
BEGIN { $ENV{HOME} ||= File::HomeDir->my_data }

at the top, which will cause N:S:Perl to look for its config file in
Local Settings\Application Data\.ssh\config . Alternatively, if you
already have an OpenSSH config file elsewhere, simply direct N:S:W32Perl
at it: you will still need to set $ENV{HOME}, even though it will be
ignored.

Ben

Thanks Ben. Look like when I download the package from here:http://www.soulcage.net/ppds/

It doesn't have that problem.

Thanks,
Mav

Well, I guess now it comes to another problem..using Par-packer(pp).
My perl (5.8.7 Build 813) on the PC, I have got a Par-packer version
that works with my perl version.
The W32Perl module install on

----------
#This is y.pl
use Net::SSH::W32Perl;
$host = "192.168.0.101";
$user = "user";
$passwd = "passwd";

my $ssh = new Net::SSH::W32Perl($host,protocol => '2,1',debug
=>1,options => ["BatchMode yes", "RhostsAuthentication no" ]);
$ssh->login($user, $passwd);
my ($out, $err, $exit) = $ssh->cmd('ls -la');

----------------

The code works fine if I do.
perl y.pl

However when I tried to using pp to create a a.exe
----------
c:\myperl>pp -o a.exe y.pl

c:\myperl>a.exe
pc: Reading configuration data /.ssh/config
pc: Reading configuration data /etc/ssh_config
pc: Connecting to 192.168.0.101, port 22.
pc: Socket created, turning on blocking...
pc: Remote protocol version 2.0, remote software version OpenSSH_4.3p2
Debi
an-9
Can't locate Net/SSH/W32Perl/SSH2.pm in @INC (@INC contains: C:
\DOCUME~1\Maveri
k\LOCALS~1\Temp\par-user\cache-1190269914/inc/lib C:\DOCUME~1\user
\LOCA
S~1\Temp\par-user\cache-1190269914/inc CODE(0xe8d788) .) at Net/SSH/
Perl.pm
line 55, <GEN3> line 1.
-----

my SSH2.pm is install in

C:\myperl>dir c:\perl\site\lib\Net\SSH\W32Perl\
Volume in drive C has no label.
Volume Serial Number is B04F-3453

Directory of c:\perl\site\lib\Net\SSH\W32Perl

09/18/2007 09:09 PM <DIR> .
09/18/2007 09:09 PM <DIR> ..
10/22/2002 06:16 AM 560 SSH2.pm

is that something I am missing when doing pp?

Thanks,
Mav

Well, I guess I find my answer:
pp -v -o a.exe --lib=C:\Perl\site\lib --module=Net/SSH/W32Perl/SSH2.pm
x.pl

Thanks,

Mav

.



Relevant Pages