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

chrislog

Member
Mar 11, 2011
9
0
51
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
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
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.
 

chrislog

Member
Mar 11, 2011
9
0
51
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.
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 :(
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
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.
 

chrislog

Member
Mar 11, 2011
9
0
51
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.
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
 
Last edited:

uKontrol

Registered
Dec 2, 2010
2
0
51
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 :

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/.ssh/lxxxxxx.pub', 'ssh-rsa AAAAB3Nxxxxxxxxx...') called at /usr/local/cpanel/Cpanel/SSH.pm line 1040
Cpanel::SSH::_importkey('passphrase', undef, 'user', 'lxxxxx', 'nxxx', 'cxxxxx.pub', 'key', 'ssh-rsa AAxxxxxx...') called at /usr/local/cpanel/Cpanel/SSH.pm line 1076
Cpanel::SSH::api2_importkey('key', 'ssh-rsa AAxxxxxxx...', 'name', 'cxxxx.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(0x10fe5bd0)', '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(0x10bdb920)') called at cpanel line 5121
main::run_standard_mode() called at cpanel line 424
 
Last edited:

chrislog

Member
Mar 11, 2011
9
0
51
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
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
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.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
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:

The key named was imported.The key named rsa-key-20110311.pub was imported.Invalid filename
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.
 

chrislog

Member
Mar 11, 2011
9
0
51
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
 

chrislog

Member
Mar 11, 2011
9
0
51
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.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
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.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
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.
 

sgluskin

Registered
Mar 31, 2011
2
0
51
I just open a ticket for the same problem, ID 1323090

I got the following very quick response:

We have a open case in regards to this (ID #48306). It's currently pending backport to all cPanel versions (case #47947). This should also be fixed in cPanel 11.29.0.11 (EDGE).
Shai Gluskin
 

santrix

Well-Known Member
Nov 30, 2008
223
2
68
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