Passing username and password via a single shell command

0

The command I am running failed to enter the password correctly

sudo ssh username@servername "echo test  test| dsmadmc"

And I get this error:

IBM Spectrum Protect  
Command Line Administrative Interface - Version, Release, Level 7.0
(c) Copyright by IBM Corporation and other(s) 1990. All Rights Reserved.

Enter your user id:  
ANS1051I Invalid user id or password
ANS1051I Invalid user id or password
ANS8023E Unable to establish a session with a server.
ANS1051I Invalid user id or password
ANS8002I Highest return code was 137.

I am trying to have a single command where I can pass both username and password on to the execution of commands.

Can anybody help me?

Anjan Kumar

Posted 2020-02-28T17:22:32.617

Reputation: 1

Are you sure you can pass the username and password to the dsmadmc command on standard input? Also, you're sending "test test" as the username. you might want "{ echo test; echo test; } | dsmadmc" to give the username and password on separate lines. – glenn jackman – 2020-02-28T17:41:44.613

I got the same error after using below suggest ones

"{ echo test; echo test; } | dsmadmc"

IBM Spectrum Protect Command Line Administrative Interface - Version 8, Release 1, Level 7.0 (c) Copyright by IBM Corporation and other(s) 1990, 2019. All Rights Reserved.

Enter your user id:
ANS1051I Invalid user id or password ANS1051I Invalid user id or password ANS8023E Unable to establish session with server. ANS1051I Invalid user id or password – Anjan Kumar – 2020-02-28T17:55:07.463

Edit your question; Please do not use comments. Your question as it’s currently written is confusing. – Ramhound – 2020-02-28T18:57:27.600

You might have to use a tool like [tag:expect] – glenn jackman – 2020-02-28T20:34:10.830

If at all possible, you should use pre-shared keys instead of passwords, especially for automation. Then you could simply specify the keyfile: ssh <username>@<server> -i <keyfile>.pub. – Cliff Armstrong – 2020-02-28T22:15:29.023

No answers