title: Switch user with "sudo su - username" using SSH keys
body: <p>I've been trying to use ssh keys in order to be able to switch from one user to another user on the same Linux machine/server by using <code>sudo su - username</code>.</p>
  
  <p>What i want to do is: I have several accounts on one server. 
  I want to lock those account with <code>passwd -l username</code>, 
  and allow access only with SSH keys, by ssh-ing from one user to the other on the same machine, e.g., :  <code>[user1@server]$  ssh user2@server</code></p>
  
  <p>I did this by copying the public key of <code>user1</code> to the <code>authorized_keys</code> file of <code>user2</code> and it works fine.</p>
  
  <p>But the other thing that i would like also to do, is to be able to <code>sudo su - user2</code> from <code>user1</code>, by using the ssh keys, so i can avoid the password prompting.</p>
  
  <p>e.g., <code>[user1@server]$ sudo su - user2</code></p>
  
  <p>I have modified the sshd_config file, and uncomment the fields:</p>
  
  <pre><code>RSAAuthentication yes
  PubkeyAuthentication yes
  AuthorizedKeysFile .ssh/authorized_keys
  PasswordAuthentication no
  </code></pre>
  
  <p>but still i am not able to do it.</p>
  
  <p>I also tried what i found on the internet regarding agent forwarding, but nothing.</p>
  
  <p>Can anyone help me on how to do this or point me to the right direction?</p>