I am trying to get some information from a Nokia router over ssh from a Linux machine.

The ssh works fine if I do this:

ssh admin@

I can enter the password, log in, run commands.

However when I do the following, it disconnects me immediately:

ssh -v admin@ 'show time'

Verbose output:
debug1: Next authentication method: password
admin@'s password: 
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_PAPER = en_US.UTF-8
debug1: Sending env LC_ADDRESS = en_US.UTF-8
debug1: Sending env LC_MONETARY = en_US.UTF-8
debug1: Sending env LC_NUMERIC = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = en_US.UTF-8
debug1: Sending env LC_IDENTIFICATION = en_US.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = en_US.UTF-8
debug1: Sending env LC_TIME = en_US.UTF-8
debug1: Sending env LC_NAME = en_US.UTF-8
debug1: Sending command: show time
debug1: channel 0: free: client-session, nchannels 1
Connection to closed by remote host.
Transferred: sent 2088, received 1840 bytes, in 0.0 seconds
Bytes per second: sent 488193.7, received 430209.0
debug1: Exit status -1

It works fine if I use an expect script to connect, send password, and then send the command.

What could be wrong?

  • It really depends on what ssh server that router is running, also whether it successfully sets path etc for non-interactive sessions. My suspicion is that it runs an old version of dropbear which is known to have similar issues. You'll have to give a bit more info on the make, model and OS version to get to the bottom of it, if it's at all possible. dropbear.ucc.asn.narkive.com/LsaFu4PH/non-interactive-commands suggests others have similar issues with old dropbear.
    – Alex Berry
    Jun 8 '17 at 11:02
  • 1
    alcatelunleashed.com/viewtopic.php?t=21551 A bit of googling shows an known issue and a workaround using a perl script, supplied by a third party. (Code review first to make sure it's not doing anything funky like sending your credentials off elsewhere).
    – Alex Berry
    Jun 8 '17 at 11:04

Thanks for all the comments.

In the end I ended up using expect as I am using a bash script to connect and pull the information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.