Bug 2514 - Usability: Key filenames / extensions make sharing private key likely.
Summary: Usability: Key filenames / extensions make sharing private key likely.
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: -current
Hardware: All All
: P5 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-10 11:31 AEDT by Warren Kumari
Modified: 2018-04-06 12:26 AEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Warren Kumari 2015-12-10 11:31:43 AEDT
Public key files have an extension (.pub), private key files do not. This makes tab completion complete to the "wrong" key file...

I *did* look for existing bugs about this, with no luck...

E.g:
In my .ssh directory there many keys. As an example:
-r--------   1 wkumari  staff   1675 Mar 13  2015 id_rsa
-r--------   1 wkumari  staff    385 Mar 13  2015 id_rsa.pub

I want to be able to use this key to login to routers and servers, so I need to share the public key with folk / copy it to a server so I can append it to an authorized_keys file / etc.

So, how do I do that?
Well, chances are I'm in a rush, so I do:
echo ~/.ssh/id_rs<tab> | email $someone
or 
scp ~/.ssh/id_rs<tab> server.example.com:~/tmp

....and, I've just emailed / copied off my *private* key. 

The issue here is that the private key has no extension (and the public one does), and so tab completion helpfully completes to the private key. This is almost *never* the right option :-P
 
This could be easily solved by making private keys also have an extension (e.g id_rsa.priv or something.


To recreate issue:
1: generate a key.
2: try do something with the key file, while in a rush / juggling many plates / being drunk. Use tab completion.
3: Feel stupid. Promise yourself you will never do this again. Go delete the key from everywhere you've ever used it. 
4: lather, rinse, repeat.
Comment 1 Damien Miller 2016-12-02 13:53:52 AEDT
If we were starting from scratch then we might consider doing this differently but changing things now will break 20+ years of workflow.
Comment 2 Damien Miller 2018-04-06 12:26:48 AEST
Close all resolved bugs after release of OpenSSH 7.7.