Clicky

I have a complicated requirement and I'm stuck at last hurdle. The requirement is that I have two users

User A and User B

I would want the user A to do sudo su - UserB and give his password ( User A) and become UserB.

Thanks

asked 11/24/2011 05:43

Peddu_bhanu's gravatar image

Peddu_bhanu ♦♦


7 Answers:
add this line to your sudoers file :

userA ALL=(userB) /bin/bash

UserA can then type in the command

sudo -u userB /bin/bash

You could also give them an alias like this

alias workasB='sudo -u userB /bin/bash'

link

answered

edster9999's gravatar image

edster9999

1) vi /etc/sudoers
2) userA       ALL= PASSWD: /bin/su - userb
link

answered 2011-11-25 at 01:54:17

torakeshb's gravatar image

torakeshb

Hi torakeshb,

You suggestion works,however user A is not prompted for his password when he does

sudo su - userb

any ideas, we need userA to enter his password.

Thanks
link

answered 2011-11-25 at 02:13:37

Peddu_bhanu's gravatar image

Peddu_bhanu

Just remove NOPASSWD: part in the above suggestion, and he would need password.
link

answered 2011-11-25 at 02:44:25

farzanj's gravatar image

farzanj

When you edit /etc/sudoers file, always use

visudo

command as it is a syntax checker as well and you would know about your syntax problems immediately
link

answered 2011-11-25 at 03:01:57

farzanj's gravatar image

farzanj

@Peddu_bhanu: did that asked for the password once? It should

link

answered 2011-11-25 at 03:03:49

torakeshb's gravatar image

torakeshb

Just making changed to torakeshb's suggestion:

1) Issue the following command:
    visudo
2) Go to the last line of the file and add the following line:
UserA       ALL= /bin/su - UserB
That is make sure to remove NOPASSWD: otherwise it would never ask password.

Use visudo as it is a syntax checker as well.
link

answered 2011-11-25 at 03:10:02

farzanj's gravatar image

farzanj

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×118

Asked: 11/24/2011 05:43

Seen: 282 times

Last updated: 11/24/2011 07:13