How can I allow user A to run commands as user B if I don't have access to root?

0

CentOS 5.6

There are two users; user A and user B. I have permissions for both and can log in as either.

I would like to be able to log in as user B, and somehow run commands as user A without knowing the password for user B.

I know this could be achieved in the sudoers file, but neither user has the ability to edit that. This is for a larger experiment, and for the sake of this question I do not have access to root (otherwise I could just log in as root and change the sudoers file accordingly).

Any ideas?

speedreeder

Posted 2011-10-02T15:52:46.423

Reputation: 1

Answers

3

set up a ssh key for user b, share the public key with user a

userb$   ssh-keygen -t dsa
userb$   scp ~/.ssh/id_dsa.pub usera@`hostname`:.ssh/authorized_keys2

you'll type a password here, but should be a 1 time thing. Then you can run commands on user a's account like so:

usera$   ssh userb@`hostname` command goes here
Example:  ssh userb@`hostname` ls -la ~

Roy Rico

Posted 2011-10-02T15:52:46.423

Reputation: 4 808

When I run ssh userb@localhost i still get prompted for a password. I have copied the public key of userb to ~/.ssh/authorized_keys (apparently authorized_keys2 is outdated although I tried it as well). – speedreeder – 2011-10-02T16:51:33.527

2check the file permissions on your .ssh dir, sometimes, if your permissons are set to group or world readable, it won't accept it. – Roy Rico – 2011-10-02T21:49:31.413

1you can type ssh -v for more verbose diagnostic information during the connection, you can add more v's for more detail (i.e. ssh -vvv userb@localhost) – Roy Rico – 2011-10-02T21:50:49.960