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.

[Case 47947] Can't create SSH Keys on cPanel User

Discussion in 'General Discussion' started by chrislog, Mar 11, 2011.

  1. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I have a cPanel user, I just created on my new cPanel installation..

    But when I try to Import an SSH Public RSA Key I get this:
    Code:
    The key named was imported.
    
    [a fatal error or timeout occurred while processing this directive] Invalid filename

    I took a look in /usr/local/cpanel/logs/error_log I noticed this:
    Code:
    [2011-03-11 18:50:46 +0000] warn [ssh::listkeys] Encountered error in ssh::listkeys: Invalid filename
    [2011-03-11 18:50:46 +0000] warn [ssh::listkeys] Encountered error in ssh::listkeys: Invalid filename
    [2011-03-11 18:51:20 +0000] die [Internal Death while parsing ./frontend/x3/telnet/keys/import.html 26244] Can't locate object method "new" via package "FileHandle" (perhaps you forgot to load "FileHandle"?) at /usr/local/cpanel/Cpanel/FileUtils.pm line 171.
    	Cpanel::FileUtils::writefile('/home/ts3/.ssh/id_rsa.pub', 'ssh-rsa <removed key>...') called at /usr/local/cpanel/Cpanel/SSH.pm line 1040
    	Cpanel::SSH::_importkey('passphrase', undef, 'user', 'ts3', 'name', 'id_rsa.pub', 'key', 'ssh-rsa <removed key>...') called at /usr/local/cpanel/Cpanel/SSH.pm line 1076
    	Cpanel::SSH::api2_importkey('key', 'ssh-rsa <removed key>...', 'name', 'id_rsa.pub') called at (eval 82) line 1
    	eval '$dataref = [Cpanel::SSH::api2_importkey(%{$rCFG})];' called at /usr/local/cpanel/Cpanel/Api2/Exec.pm line 84
    	Cpanel::Api2::Exec::api2_exec('SSH', 'importkey', 'HASH(0x26b6af0)', 'HASH(0x17ed620)') called at cpanel line 607
    	main::real_cpexectag('<?cp SSH::importkey($LANG{\'SSHKeyImportText1\'} % $LANG{\'SSHKe...') called at cpanel line 3879
    	main::dotag_finished_headers(0) called at cpanel line 3704
    	main::cpanel_parseblock('<cpanel setvar="headerimg=../../images/topmysql.gif">^J<cpanel se...') called at cpanel line 3612
    	main::cpanel_parse('GLOB(0x22afa70)') called at cpanel line 5121
    	main::run_standard_mode() called at cpanel line 424
    
    
    [2011-03-11 18:51:20 +0000] warn [cpanel] Unable to run [Cpanel::SSH::api2_importkey(2/8)]; Bad file descriptor at /usr/local/cpanel/Cpanel/Api2/Exec.pm line 90
    	Cpanel::Api2::Exec::api2_exec('SSH', 'importkey', HASH(0x26b6af0), HASH(0x17ed620)) called at cpanel line 607
    	main::real_cpexectag('<?cp SSH::importkey($LANG{\'SSHKeyImportText1\'} % $LANG{\'SSHKeyImportText2\'},name) name=$FORM{\'keyname\'}.pub,key=$FORM{\'pubkey\'} ?>') called at cpanel line 3879
    	main::dotag_finished_headers(0) called at cpanel line 3704
    	main::cpanel_parseblock('<cpanel setvar="headerimg=../../images/topmysql.gif">\x0A<cpanel setvar="dprefix=../../">\x0A<cpanel Branding="include(stdheader.html)">\x0A\x0A<style type="text/css">\x0A<?cp Branding::spritelist(.spriteicon_img_mini {float:left;margin-right:5px;background: url\\{leftparenthesis}%\\{rightparenthesis};} %,spriteurl,images::#icon-${img}_mini {background-position\\{colon}0 -${cssposition}px;width\\{colon}${width}px;height\\{colon}${height}px; }:) imgtype=icon,subtype=img,method=scale_60percent,format=png,img=ssh-shell-access ?>\x0A\x0A</style>\x0A<div class="body-content">\x09<div class="h1Title"><div class="spriteicon_img_mini" id="icon-ssh-shell-access_mini"></div><cpanel langprint="SSHImportKey"></div>\x0A\x0A<p>\x0A<?cp SSH::importkey($LANG{\'SSHKeyImportText1\'} % $LANG{\'SSHKeyImportText2\'},name) name=$FORM{\'keyname\'},key=$FORM{\'privkey\'} ?>\x0A<cpanelif $CPERROR{\'ssh\'}>\x0A    <cpanel print="$CPERROR{\'ssh\'}">\x0A</cpanelif>\x0A<?cp SSH::importkey($LANG{\'SSHKeyImportText1\'} % $LANG{\'SSHKeyImportText2\'},name) name=$FORM{\'keyname\'}.pub,key=$FORM{\'pubkey\'} ?>\x0A\x0A<cpanelif $CPERROR{\'ssh\'}>\x0A    <cpanel print="$CPERROR{\'ssh\'}">\x0A</cpanelif>\x0A\x0A</p>\x0A \x0A<div class="return-link"><a href="index.html">&larr; <cpanel langprint="SSHBack"></a></div>\x0A</div>\x0A<cpanel Branding="include(stdfooter.html)">\x0A') called at cpanel line 3612
    	main::cpanel_parse(GLOB(0x22afa70)) called at cpanel line 5121
    	main::run_standard_mode() called at cpanel line 424
    [2011-03-11 18:51:20 +0000] warn [ssh::importkey] Encountered error in ssh::importkey: Invalid filename
    [2011-03-11 18:52:52 +0000] warn [ssh::listkeys] Encountered error in ssh::listkeys: Invalid filename
    [2011-03-11 18:52:52 +0000] warn [ssh::listkeys] Encountered error in ssh::listkeys: Invalid filename
    

    Any help with this issue would be greatly appreciated.. I've been trying to find a solution for a while now, and no luck :(


    Cheers,

    Chris
     
    #1 chrislog, Mar 11, 2011
    Last edited: Mar 11, 2011
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Chris,

    Please provide the exact steps being used for importing the key. Also, can you confirm the key itself was correctly generated? Was cPanel used to generate the key or some other system?

    Thanks.
     
  3. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hey, I do the following:
    Login in to cPanel > Security: SSH/Shell Access > Manage SSH Keys > Import Key > Enter the filename: id_rsa > Enter the Public Key > Import > Then the error appears.

    The Key works on another one of my servers, which is using WHM/cPanel and imports without any issues.
    I am in the process of setting up another server and decomissioning the old one, so the Installation I am having an issue with adding SSH Keys with is on a 45-Day Trial License, but my license will be transferred over once I'm finished setting up the new server..

    Also the SSH Key was generated using PuTTY Key Generator. I use this key for a few other things too and never had any issues.

    Hope this helps,

    Cheers

    Chris

    So far this has been a troublesome task :(
     
  4. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Posted a quick reply, but I think it needs approved?

    Did the reply go through? o_O
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The reply appears for me because I have access to approve moderated posts. I removed the key you'd pasted because it's a security risk to post it.

    Next, don't put a name for the key. Finally, are you certain you are pasting the public key? The public key normally ends in .pub, so I'm thinking it might be the private key you are pasting into the box.
     
  6. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    PuTTY Key Gen displays it in an SSH line format for copying pasting, it states its the Public key, which is the one I am copying over, I've never had this issue with it before



    I also get the same error when not specifying a filename:
    "The key named was imported.

    [a fatal error or timeout occurred while processing this directive] Invalid filename"

    Edit: Any key I try to import does not work, if that helps
     
    #6 chrislog, Mar 11, 2011
    Last edited: Mar 11, 2011
  7. uKontrol

    uKontrol Registered

    Joined:
    Dec 2, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi, I just started having this problem today as well, I think this last update might have messed something up. I use this part of cpanel frequently and only today I ran into this problem.

    When i click on [a fatal... I get this :

     
    #7 uKontrol, Mar 11, 2011
    Last edited: Mar 11, 2011
  8. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I also get a similar error when clicking "[a fatal..."

    SSH-Key Removed where stated by <KEY REMOVED>

    Code:
    Can't locate object method "new" via package "FileHandle" (perhaps you forgot to load "FileHandle"?) at /usr/local/cpanel/Cpanel/FileUtils.pm line 171.
    	Cpanel::FileUtils::writefile('/home/ts3/.ssh/id_dsa.pub', 'ssh-rsa <KEY REMOVED>...') called at /usr/local/cpanel/Cpanel/SSH.pm line 1040
    	Cpanel::SSH::_importkey('passphrase', undef, 'user', 'ts3', 'name', 'id_dsa.pub', 'key', 'ssh-rsa <KEY REMOVED>...') called at /usr/local/cpanel/Cpanel/SSH.pm line 1076
    	Cpanel::SSH::api2_importkey('key', 'ssh-rsa <KEY REMOVED>...', 'name', '.pub') called at (eval 82) line 1
    	eval '$dataref = [Cpanel::SSH::api2_importkey(%{$rCFG})];' called at /usr/local/cpanel/Cpanel/Api2/Exec.pm line 84
    	Cpanel::Api2::Exec::api2_exec('SSH', 'importkey', 'HASH(0x2c65930)', 'HASH(0x17ed620)') called at cpanel line 607
    	main::real_cpexectag('<?cp SSH::importkey($LANG{\'SSHKeyImportText1\'} % $LANG{\'SSHKe...') called at cpanel line 3879
    	main::dotag_finished_headers(0) called at cpanel line 3704
    	main::cpanel_parseblock('<cpanel setvar="headerimg=../../images/topmysql.gif">^J<cpanel se...') called at cpanel line 3612
    	main::cpanel_parse('GLOB(0x285c9c0)') called at cpanel line 5121
    	main::run_standard_mode() called at cpanel line 424
     
    #8 chrislog, Mar 11, 2011
    Last edited: Mar 11, 2011
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Can you both please post your cPanel version numbers?

    Code:
    cat /usr/local/cpanel/version
     
  10. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Using this version:

     
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    I'm going to be testing this now to see the results. I'm generating an SSH-2 RSA key using puttygen in Windows, then going to try to import that key into WHM on that version of cPanel. I'll get back once I have the results. We may need to have you both open up a ticket regardless.
     
  12. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    While I am getting invalid filename, the key itself does not show any fatal errors and it does show up on the list. Here's the message when I try to import it:

    It also does let me authorize it. Please open up a ticket for us to check into this further using WHM > Support Center > Contact cPanel or via the link in my signature. Please post the ticket number here once the ticket has been opened. Please note that you might want to try a forced cPanel update prior to opening the ticket:

    Code:
    /scripts/upcp --force
    Of note, I tested this on both 11.28.86-RELEASE_51183 and 11.28.86-CURRENT_51183 machines. I used puttygen to generate an SSH-2 RSA key on a Windows XP box.
     
  13. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Tried the forced update, but it did not change my problem.

    I submitted the ticket as requested, the Ticket ID is: 1277149

    Thanks for your help, I really appreciate it!

    Cheers

    Chris
     
  14. chrislog

    chrislog Member

    Joined:
    Mar 11, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I forgot to mention, the License on that server is just a Trial, at the moment, since I'm transferring stuff from an old server to this one. If you need the support number from the other cpanel (licensed one) then I can give you that.
     
  15. uKontrol

    uKontrol Registered

    Joined:
    Dec 2, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I followed your steps above:


    Code:
    Checked 1 files for 2 user(s), 1 ok, 0 broken
    ...Done
    root@xxxxx [~]# cat /usr/local/cpanel/version
    11.28.86-RELEASE_51183root@xxxxxx [~]#
    And using PuttyGen on Windows XP still reproduced the error.

    Support Request Id 1277530

    Thank you
     
  16. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    We are working on an internal case for submitting for this issue. When I tested, I was using WHM rather than cPanel due to misunderstanding that it was cPanel individual user login area. Upon testing in cPanel, the issue can be reproduced. To correct the issue based on what we have found, you would use the following diff to correct it:

    Code:
    --- FileUtils.pm.orig    2010-12-07 00:36:07.000000000 +0300
    +++ FileUtils.pm    2011-03-12 02:53:14.000000000 +0300
    @@ -168,7 +168,8 @@
     sub writefile {
         my $filename = shift;
         my $contents = shift;
    -    my $fh = FileHandle->new;
    +    use IO::File;
    +    my $fh = new IO::File;
     
         if ( open $fh, '>', $filename ) {
             print $fh $contents;
    This would be at /usr/local/cpanel/Cpanel location for the FileUtils.pm file.

    Once I have the case number, I will update the thread with that information.
     
  17. Branko

    Branko Active Member
    PartnerNOC

    Joined:
    Sep 16, 2005
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    DataCenter Provider
    Any updates on this?

    Applying the patch fixes the issue, but every time daily cpanel update runs it reverts the changes back and importing won't work.
     
  18. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Branko,

    Unfortunately, there is no set ETA on this case. Please open a ticket and mention this case number if you haven't already done so for us to attach this to 47947

    I cannot recommend setting FileUtils.pm to immutable to prevent it from being updated again, so I'm not certain how else to resolve this besides the case being pushed into the existing versions after it has gone through development and quality assurance channels.

    Thanks.
     
  19. sgluskin

    sgluskin Registered

    Joined:
    Mar 31, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I just open a ticket for the same problem, ID 1323090

    I got the following very quick response:

    Shai Gluskin
     
  20. santrix

    santrix Well-Known Member

    Joined:
    Nov 30, 2008
    Messages:
    223
    Likes Received:
    2
    Trophy Points:
    18
    To save just submitting more tickets for the same issue to cpanel, does anyone have an update to this issue, or when it might be fixed in the RELEASE tree?

    Steve
     
Loading...

Share This Page