-1

I am using a script that executes the following command in a bunch of servers:

sshpass -p password ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no user@server 'sudo yum -y install NessusAgent.x86_64'

For most servers it works using sudo, but in some of them I only have pbrun bash for executing commands with privileges.

My issue is that when I make changes to the command:

sshpass -p password ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no user@server 'pbrun bash; yum -y install NessusAgent.x86_64'

It just hangs up in there and I get no response until I just hit CTRL-C to kill it. I tried ssh with -t flag, but it puts me straight into the target server's shell and that's not what I want.

Is there a way to use pbrun and execute the command without the issues I am experiencing?

DrizzerX
  • 3
  • 4
  • I"m not familiar with `pbrun`, but `pbrun bash;` seems to me that you're opening a bash shell and waiting for input. I bet you could type `/bin/ls -l` and get a response. Not sure how to get around this. Good luck. – shellter Aug 14 '20 at 23:04

1 Answers1

2

I have never used power broker, but I think your problem is the ; ...

Can you try:

'pbrun bash -c "yum -y install NessusAgent.x86_64"'

instead of your

'pbrun bash; yum -y install NessusAgent.x86_64'
tink
  • 14,342
  • 4
  • 46
  • 50