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.

Can't log in with ssh keys

Discussion in 'Security' started by kers7754, Jul 22, 2014.

  1. kers7754

    kers7754 Active Member

    Joined:
    Jan 13, 2011
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    I followed this tutorial and did this many times:
    Server Security and SSH Key Authentication

    The public key correct imports into WHM root key and Manage Authorization is set to authorized.

    But when I ssh -p {customport} user@mydomain.com I always get this error:

    Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

    As soon as I allow password authentication, the SSH works but asks me for my password and doesn't use the key.

    Any ideas?
     
  2. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    942
    Likes Received:
    57
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    try using the -i flag (identity) when you log in, ie:

    ssh -i your_private.key -p {customport} user@mydomain.com
     
  3. kers7754

    kers7754 Active Member

    Joined:
    Jan 13, 2011
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    That didn't seem to work either. :(

    At one point I disabled root ssh access and forced users to ssh as a different user then su - to get root access. But checking the sshd_config, I see that PermitRootLogin yes.

    Any other suggestions?

    - - - Updated - - -

    Ah.. so it look like when I ssh with root@hostname.com, I get an access denied. So apparently I am not able to ssh as root. I would imaging that might be my problem as to why I can't ssh with a keypair.
     
  4. kers7754

    kers7754 Active Member

    Joined:
    Jan 13, 2011
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Alright.. it turns out that in my sshd_config file, I had the following:

    AllowUsers kershnerd,root

    Removing that line and forcing password authentication to off now works!

    Thanks for looking into this!
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page