Ssh to role

Hi all

I need to run a command that only a role user and root can run, I need to run that command remotely by script but the roles ask for a password.

Ex. from serverA with userA to serverB with userB:
userA can ssh serverB using userB without askink for a password.

ssh userB@serverB   su  roleuser -c "/usr/sbin/savegroup" 

user1 es a user tha can do su to roleuser
roleuser is a role that can execute /usr/sbin/savegroup

the matter is that when I try to do tha remotely it says : su: Sorry

how can i achieve my goals

Thanks for any help

In the same way you got it working in one way... Sorry I am unclear with what you wrote, is the line between code tags work?
Or are you saying you cannot... Because truly already that line is unclear...

Thanks vbe for responding

What I intent to do is to run a command remotely using a role user.
In the target host the command will be execute by a role user, not a normal usr.

That's it all that I need to know

---------- Post updated at 09:58 AM ---------- Previous update was at 09:44 AM ----------

The command will not be executed interactivilly, it will be executed automatically with a script invoked by a cron in a server that is going to do a ssh to the intended server and executed the command with a role user on the target server.

Hello,
I run remote commands on servers all the time, though we use sudo.

ssh server sudo command

Sometimes ssh has issues and the commands works better with the -t option, try that.

ssh -t server command

I hope this helps.