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 sudo su - username
.
What i want to do is: I have several accounts on one server.
I want to lock those account with passwd -l username
,
and allow access only with SSH keys, by ssh-ing from one user to the other on the same machine, e.g., : [user1@server]$ ssh user2@server
I did this by copying the public key of user1
to the authorized_keys
file of user2
and it works fine.
But the other thing that i would like also to do, is to be able to sudo su - user2
from user1
, by using the ssh keys, so i can avoid the password prompting.
e.g., [user1@server]$ sudo su - user2
I have modified the sshd_config file, and uncomment the fields:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
but still i am not able to do it.
I also tried what i found on the internet regarding agent forwarding, but nothing.
Can anyone help me on how to do this or point me to the right direction?
sudo
has nothing to do with SSH and sshd
config.
What you really want is a PAM module that will use SSH public keys. I'm not sure what are your reasons as the whole idea seems a bit strange, but, well. pam_ssh
is the module that does this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With