1

I have a faceless account on a remote machine.i.e, i do not have to insert my password when doing a ssh.My question is that what should be my code if i do not have to use the password through the perl code.In the shown code its still asking for a password

 $cmd="cat /read.log";
 my $ssh = Net::SSH::Perl->new($host, protocol => '1,2', debug => 1);
 $ssh->login($user, $pass);
 my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
 print $stdout, "\n";

2 Answers 2

1

While standard ssh checks for id_rsa and id_dsa in your ~/.ssh/ folder when using challenge-response authentication, Net::SSH::Perl only looks in $ENV{HOME}/.ssh/identity for RSA and $ENV{HOME}/.ssh/id_dsa for DSA. I suspect this is the cause of the problem, and you can solve this by adding identity_files to the parameters passed to the new method.

Check your identities by executing ls ~/.ssh/ and look for a file called id_rsa. Then simply set identity_files to include the appropriate paths.

Sign up to request clarification or add additional context in comments.

4 Comments

K i do not have a file as id_rsa in ls ~/.ssh/ Can this not be hanled in the code itself..
I am almost afraid to ask... but do you have any id_ files in ~/.ssh?
They run some programs to do the passwordless login in hte company .although i know that ssh keys is the actuall way of implementing the passwordless login
In that case, you might be better off just using ssh, since it supports executing a command on the remote side. e.g. ssh $server ls -l' will return a listing of the login dir and exit.
1

You should give the identity_files argument to Net::SSH::Perl->new. Check where your identity files are located and compare to the module docs:

identity_files

A list of RSA/DSA identity files to be used in RSA/DSA authentication. The value of this argument should be a reference to an array of strings, each string identifying the location of an identity file. Each identity file will be tested against the server until the client finds one that authenticates successfully.

If you don't provide this, RSA authentication defaults to using $ENV{HOME}/.ssh/identity, and DSA authentication defaults to $ENV{HOME}/.ssh/id_dsa.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.