Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

userb$   ssh-keygen -t dsa
userb$   scp ~/.ssh/ 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 ~
share|improve this answer
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 Oct 2 '11 at 16:51
check 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 Oct 2 '11 at 21:49
you 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 Oct 2 '11 at 21:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.