Search code examples
linuxshellsshremote-accessopenssh

SSH remote execute command after using pbrun


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?


Solution

  • 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'