0

I am just starting to use Net::SSH::Perl and it seems that I ranning into something weird. If I set the interactive flag to 1 and input my password I am am to login remotely to the machine via ssh but if I leave the interactive flag off or set it to 0 the login fails. I confirm that I am able to use Net::SSH::Perl to log into my local machine so it must be something that I am doing wrong for this particular remote machine, which the under laying OS is SuSE. I also confirmed that I am able to ssh to the remote machine from a terminal window.

use Net::SSH::Perl;
my $cmd = 'uptime';
my $ssh = Net::SSH::Perl->new($host, interactive=> 0, debug => 1);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print $stdout;

Below is the logs that are output from debug when the interactive flag is set to 0.

localhost.localdomain: Reading configuration data /home/user/.ssh/config
localhost.localdomain: Reading configuration data /etc/ssh_config
localhost.localdomain: Connecting to 1.1.1.1, port 22.
localhost.localdomain: Remote version string: SSH-2.0-OpenSSH_5.1

localhost.localdomain: Remote protocol version 2.0, remote software version OpenSSH_5.1
localhost.localdomain: Net::SSH::Perl Version 1.38, protocol version 2.0.
localhost.localdomain: No compat match: OpenSSH_5.1
.
localhost.localdomain: Connection established.
localhost.localdomain: Sent key-exchange init (KEXINIT), wait response.
localhost.localdomain: Algorithms, c->s: 3des-cbc hmac-sha1 none
localhost.localdomain: Algorithms, s->c: 3des-cbc hmac-sha1 none
localhost.localdomain: Entering Diffie-Hellman Group 1 key exchange.
localhost.localdomain: Sent DH public key, waiting for reply.
localhost.localdomain: Received host key, type 'ssh-dss'.
localhost.localdomain: Host '1.1.1.1' is known and matches the host key.
localhost.localdomain: Computing shared secret key.
localhost.localdomain: Verifying server signature.
localhost.localdomain: Waiting for NEWKEYS message.
localhost.localdomain: Send NEWKEYS.
localhost.localdomain: Enabling encryption/MAC/compression.
localhost.localdomain: Sending request for user-authentication service.
localhost.localdomain: Service accepted: ssh-userauth.
localhost.localdomain: Trying empty user-authentication request.
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.
localhost.localdomain: Next method to try is publickey.
localhost.localdomain: Publickey: testing agent key '[email protected]'
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.
localhost.localdomain: Next method to try is publickey.
localhost.localdomain: Publickey: testing agent key 'user'
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.
localhost.localdomain: Next method to try is publickey.
Permission denied at /home/user/workspace/perl-random/avamar_ssh.pl line 4.

I am guessing I am doing something wrong, so if someone could point in the right direction that would be awesome.

Thanks.

3
  • I'm not sure why you describe this as "weird". 'publickey' authentication is failing. In interactive mode, it falls back to prompting you for your password ('keyboard-interactive'), which works; in non-interactive mode, that's obviously not an option, so it fails. Have you made an attempt to set up public-key authentication? Commented Aug 7, 2015 at 23:16
  • Public-key authentication is not an option for what I need the script to accomplish. Commented Aug 8, 2015 at 0:01
  • Based on what you've told us public key sounds like the way to go. If you eliminate the logical option based on facts we don't have I'm not sure what help we can give. Or tell us what the other real non-arbitrary limitations are and we might have a chance to figure it out. Commented Aug 8, 2015 at 13:30

1 Answer 1

1

This part:

localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.

means that the server is allowing two methods for authenticating:

  • publickey — public-key authentication
    • You mention in a comment that this not an option for you.
  • keyboard-interactive — where you enter a password
    • It should hardly come as a surprise that this only works in interactive mode.

So, what you're trying to do is not possible.

The good news is, this sounds like the X-Y Problem. If you give us more details about your real problem, we may be able to suggest a better approach.

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

1 Comment

Yea... I realize that after my last comment... oh well.. will think of another approch to log into the appliances that I have and run a few commands.

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.