import failure: Invalid file format

Bug #372608 reported by Patrick Ben Koetter
114
This bug affects 23 people
Affects Status Importance Assigned to Milestone
seahorse (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Importing a SSH private key using File -> Import fails.
The key is valid. Adding it to the ssh key agent on command line works as expected.
This used to work in older Ubuntu versions and got lost on the way to Jaunty.

Revision history for this message
Lars Mai (mailars) wrote :

I can confirm that it does not work in jaunty (dont know about earlier versions).

I have two private ssh keys in my .ssh directory:
- one RSA-key generated with ssh-keygen - it gets picked up automatically as expected by seahorse
- one DSA-key generated with putty, and exported through putty to openssh format - this key is not automatically recognized by seahorse, and I am unable to import it manually ("Invalid file format")

The one that is not working is protected by a passphrase (encrypted), I wonder if this is maybe relevant? It works with ssh-add from the command line.

Revision history for this message
Martin Meyer (elreydetodo) wrote :

This may be related to bug 397145 which I just filed. Basically I suspect that seahorse and gnome-keyring-manager refuse to recognize the id_rsa file because it isn't recognized as the proper mime type. Can you check your key file to see what mime type it is identified as?

Also, can someone who this actually works for check to see what mime type their file is reported as?

Revision history for this message
Lars Mai (mailars) wrote :

Thank you for the hint, but this is unrelated I believe - both my keys are identified as "application/octet-stream" by xdg-mime.

But I just discovered that it seems to be related to DSA keys in seahorse in general. I was not able to generate a DSA key with ssh-keygen or puttygen which would be accepted by seahorse. I can generate a DSA key in seahorse, which then gets listed properly. However, if I remove that key and try to re-import a copy of it, I get the "Invalid file format" error message from seahorse.

Steps to reproduce:

1. Generate a SSH-key in seahorse (encryption type: dsa)
2. Enter passphrase; key is now listed under "My Personal Keys"
3. Backup the just generated key: cp ~/.ssh/id_dsa* /some/where
4. Delete the key in seahorse
5. Import the backuped key: File > Import
=> Error Message: "Invalid file format"

Seahorse version is 2.26.1, running on Ubuntu Jaunty.

Revision history for this message
Steven (steven3000) wrote :

I get the same problem as comment #4 but using RSA keys.
Version 2.26.1 on Jaunty,

Revision history for this message
Anders Norgaard (anders-norgaard) wrote :

The mime-type checking that Seahorse uses does seem broken to me.

http://git.gnome.org/cgit/seahorse/tree/libseahorse/seahorse-util.c#n793

which i think calls

http://git.gnome.org/cgit/glib/tree/gio/gcontenttype.c#n319

which has no chance of returning eg. "application/x-ssh-key"

Revision history for this message
UnSandpiper (aybora) wrote :

Experience the same behavior under Karmic beta.

Revision history for this message
Anders Norgaard (anders-norgaard) wrote :

Is seahorse simply linked against the wrong library in Ubuntu?

I tried filing https://bugzilla.gnome.org/show_bug.cgi?id=597310

with this info

anders@salt2:~/devel/gtktest$ cat test.c
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gstdio.h>

int main( int argc, char *argv[] ){
    gboolean uncertain;
    gchar *mime;
    mime = g_content_type_guess ("/home/anders/.ssh/id_dsa", NULL, 0,
&uncertain);
    g_print ("%s \n", mime);
    return 0;
}
anders@salt2:~/devel/gtktest$ gcc test.c -o test `pkg-config --cflags --libs
gtk+-2.0`
anders@salt2:~/devel/gtktest$ ./test
application/octet-stream
anders@salt2:~/devel/gtktest$ xdg-mime query filetype ~/.ssh/id_dsa
application/x-pem-key

Interestingly there is a difference between gnomevfs-info and gvfs-info

anders@salt2:~/devel/gtktest$ gnomevfs-info ~/.ssh/id_dsa 2> /dev/null | grep MIME | cut -d ":" -f 2 | sed s/"^ "//
application/octet-stream
anders@salt2:~/devel/gtktest$ gvfs-info ~/.ssh/id_dsa 2> /dev/null | grep standard::content-type | cut -d ":" -f 4 | sed s/"^ "//
application/x-pem-key

Revision history for this message
gmayer (gunther-mayer) wrote :

I can confirm that on karmic 64bit with all latest updates applied I cannot manually import ANY keys, rsa, dsa, encrypted or not as it always complains about "Invalid file format". Makes the application kinda useless for any keys other than "~/.ssh/id_rsa"...

Revision history for this message
Martin Meyer (elreydetodo) wrote :

In bug 397145 it was pointed out that importing your ssh keys happens automatically if ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub are both present. Did you maybe rename your public key file? That was what make the SSH agent stuff not work on my system. I haven't tested, but I suspect that key importing might fail if the public key file isn't present as well. Is that's your problem maybe?

Revision history for this message
runout (office-runout) wrote :

i figured out, the name of the files doesn't matter as long as both files have the same name (public key with .pub) and are in the same directory (~/.ssh/).

but the import functionality should be fixed.

Revision history for this message
ski (skibrianski) wrote :

Same problem, this time with a pgp key. Running karmic. An identical import worked fine on hardy.

Revision history for this message
ski (skibrianski) wrote :

Forgot to add, the workaround I used was to rename my (private) pgp keys as foo.pgp, then I was able to import them just fine.

Revision history for this message
Bill (hudacek) wrote :

I *was* having the same problem here in Jaunty. This should be a bug, and should be fixed. It was not a mime-type issue for me (though I saw the same /symptoms/ as others report).

Copying the public key line out of authorized_keys2 and creating id_dsa.pub, then running seahorse, there was not even a need to import the key! It just magically shows up in the list (though it's not 'unlocked', mind you, as you have not been challenged yet).

And - of course - now when I try 'ssh other-host', /usr/bin/gnome-keyring-daemon prompts in X with the system modal window, as it should, instead of the text prompt (which does not store it in the agent....meaning every 'ssh' command from a different pty requires the password again).

It was hard to understand as strace of 'ssh' looked the same except for text prompt vs X11 prompt........turns out now that seahorse would not load the contents of the private key file unless the pub key was on disk. Note that I did not strace the daemon, just the ssh command.

I'm glad to have found a workaround, but this should be fixed - at least give the message that the pub key file is not found, so everyone else can have an AH-HA moment rather than seeming to not support DSA keys :-)

Revision history for this message
Nicholas Robinson-Wall (nickrw) wrote :

I had a similar issue - but I would never get any error message displayed, seahorse would just exit with no message, leaving behind a partial copy of the key missing a few bytes from the end at ~/.ssh/id_rsa (or ~/.ssh/id_rsa.1 if that already existed). If I ran from console I would see the same as described in this debian bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579275

** (seahorse:9557): WARNING **: SSH command failed: (1)
** (seahorse:9557): WARNING **: SSH error output: load failed

I tried what poster #14 suggested (thanks!) and it worked with no import required.

Colan Schwartz (colan)
Changed in seahorse (Ubuntu):
status: New → Confirmed
Revision history for this message
Pravin Paratey (pravinp) wrote :

To get seahorse to automatically add the key, you will have to export the public key and save it as id_rsa.pub.

$ ssh-keygen -y
Enter file in which the key is (/home/pravin/.ssh/id_rsa):
Enter passphrase:

And then save the public key generated in a file called id_rsa.pub (using copy+paste)

Revision history for this message
James Lewis (james-fsck) wrote :

This is reported fixed in the upstream bug tracker, but currently seahorse 3.4 has not landed in 12.04, I know some Gnome 3.4 applications are making it into the LTS but it's not clear if this will happen for seahorse before release, if anyone has more info on the status of that it might help here.

I'll try to replicate this in 12.04 but if anyone else can confirm if they still see this issue with the version in 12.04.

Revision history for this message
James Lewis (james-fsck) wrote :

I can confirm that I was successfully able to import an ssh key using seahorse, I got a segfault as documented in this bug:-

https://bugzilla.redhat.com/show_bug.cgi?id=751515

But my key was imported successfully on 12.04.

So... half way there... now we just need to do it without crashing. ;)

Revision history for this message
Sämy (saemy-zehnder) wrote :

I had a similar problem when the public key spaned multiple lines (however, using it with ssh worked).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.