The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using the root SSH key to login as any cPanel user

Discussion in 'Security' started by jcwacky, Mar 9, 2013.

  1. jcwacky

    jcwacky Member

    Joined:
    Sep 4, 2002
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. LDHosting

    LDHosting Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    93
    Likes Received:
    2
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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
     
  3. jcwacky

    jcwacky Member

    Joined:
    Sep 4, 2002
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    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?
     
  4. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    940
    Likes Received:
    55
    Trophy Points:
    28
    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.
     
  5. jcwacky

    jcwacky Member

    Joined:
    Sep 4, 2002
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  6. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    940
    Likes Received:
    55
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    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.
     
    #6 quizknows, Mar 13, 2013
    Last edited: Mar 13, 2013
Loading...

Share This Page