Using the root SSH key to login as any cPanel user

jcwacky

Active Member
Sep 4, 2002
30
2
158
I have successfully setup the root SSH key on my cPanel server, and can login from my Mac as root without requiring a password.

My question is: is it possible to login as any other cPanel user account, using this same SSH key? To avoid having to create a key for every account on the server? (I manage all the accounts on the server myself).

Thanks
James
 

LDHosting

Well-Known Member
Jan 19, 2008
93
2
58
cPanel Access Level
Root Administrator
I have successfully setup the root SSH key on my cPanel server, and can login from my Mac as root without requiring a password.

My question is: is it possible to login as any other cPanel user account, using this same SSH key? To avoid having to create a key for every account on the server? (I manage all the accounts on the server myself).

Thanks
James
If you're logged in as root, can you not just su to the new user?

Code:
su - OTHERUSER
*Do whatever you have to do*
exit
 

jcwacky

Active Member
Sep 4, 2002
30
2
158
Ah, thanks, didn't realise you could do it as simple as that.

I'll need to see if I can get my deployment apps can support that method. Are there any other ways of achieving the same thing if not?
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
cPanel Access Level
DataCenter Provider
Likely your deployment apps won't be able to use su, however, you can use one ssh key on multiple accounts. I wouldn't recommend using your root key, but if you have a public key and want to use the same private key locally to gain access to the accounts, you can just

Code:
cat /whatever/public/key >> /home/$USERNAME/.ssh/authorized_keys
Repeat for whatever other user accounts you want to use that key for. If it doesn't work right away, ensure proper ownership/perms on the respective .ssh directories and authorized_keys files.
 

jcwacky

Active Member
Sep 4, 2002
30
2
158
Thanks, is it possible to just enable this for all existing accounts and for all news ones? Don't really want an extra step when setting up new accounts.
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
cPanel Access Level
DataCenter Provider
Thanks, is it possible to just enable this for all existing accounts and for all news ones? Don't really want an extra step when setting up new accounts.
You could probably just put the public key in /root/cpanel3-skel/.ssh/authorized_keys and it should copy that whenever root makes a new account via WHM.
 
Last edited: