# Ssh to role

**URL:** <https://community.unix.com/t/ssh-to-role/350892>\
**Category:** Solaris\
**Created:** [March 4, 2015, 7:56am UTC](https://community.unix.com/t/ssh-to-role/350892 "2015-03-04T07:56:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juanramos100](https://community.unix.com/letter_avatar/juanramos100/32/5_5575768a8748004e209b776fc1b2916d.png) [@juanramos100](https://community.unix.com/u/juanramos100)\
**Post date:** [March 4, 2015, 7:56am UTC](https://community.unix.com/t/ssh-to-role/350892/1 "2015-03-04T07:56:11Z")

</div>

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.

```nohighlight
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

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [March 4, 2015, 8:26am UTC](https://community.unix.com/t/ssh-to-role/350892/2 "2015-03-04T08:26:40Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![juanramos100](https://community.unix.com/letter_avatar/juanramos100/32/5_5575768a8748004e209b776fc1b2916d.png) [@juanramos100](https://community.unix.com/u/juanramos100)\
**Post date:** [March 4, 2015, 8:58am UTC](https://community.unix.com/t/ssh-to-role/350892/3 "2015-03-04T08:58:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bitlord](https://community.unix.com/letter_avatar/bitlord/32/5_5575768a8748004e209b776fc1b2916d.png) [@bitlord](https://community.unix.com/u/bitlord)\
**Post date:** [March 4, 2015, 3:58pm UTC](https://community.unix.com/t/ssh-to-role/350892/4 "2015-03-04T15:58:29Z")

</div>

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

```nohighlight
ssh server sudo command

```

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

```nohighlight
ssh -t server command

```

I hope this helps.
