LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-27-2008, 05:37 AM   #1
dmor
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Rep: Reputation: 15
Interesting question about Private/Public Key


Hello all!

I have a little question about Public/Private Keys.

For this question, lets talk about the keys concerning to ssh authentication.

My question is:

If I have my private key but I don't have the public key, if the the public key on the remote computer has been deleted can I restore it?

My question is if I can restore public key, from private key?

Thanks!
 
Old 08-27-2008, 05:48 AM   #2
fatra2
Member
 
Registered: Feb 2004
Location: Switzerland
Distribution: Fedora - RedHat - Mandrake - OpenSuse
Posts: 216

Rep: Reputation: 35
Hi there,

I am not an expert on the question of keys and security, but I believe you can restore your keys, or create new ones, with
Code:
openssl
For the details on how to do so, you can search the web for example and more explanation.

Cheers
 
Old 08-27-2008, 08:35 AM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by dmor View Post
If I have my private key but I don't have the public key, if the the public key on the remote computer has been deleted can I restore it?
Your public and private keys are the by-product of a mathematical computation. Think of mathematical computation as division and the public key as the result. The private key is the remainder. If all you have is the remainder, there is no way to use it to compute the result unless you still have the original two numbers used in the computation.

Due to the fact that key generators use random number generators and entropy gatherers, there is no way to reproduce the exact mathematical sequence that generated your two keys. This is by design. If someone could use one key to derive the other key, it would open the door to a lot of attacks.

That being said, if you are using GPG or PGP, you should have key ring files that have stored copies of both your public and private keys. The reason you need to keep a copy of your public key is so that you can encrypt your messages to yourself to allow you to read them later. If you do not encrypt to yourself, only the recipient can read your message.

EDIT: Pardon me. I glossed over the part about this being restricted to ssh.

Last edited by David1357; 08-27-2008 at 11:12 AM. Reason: Added note about GPG and PGP keyrings. Added apology for missing restriction to ssh.
 
Old 08-27-2008, 09:41 AM   #4
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
Dunno about this one. I've deleted my public key accidentally several times, but was able to rebuild a public key by using the private key. Note that this is for SSH key pairs, though, so in the case of PKI, it may be different (I thought the technology was very similar, though).
 
Old 08-27-2008, 09:47 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
ssh-keygen -y -f name-of-private-key > name-of-rebuilt-public-key
See man ssh-keygen for future reference.

Last edited by colucix; 08-27-2008 at 09:49 AM.
 
Old 08-27-2008, 10:50 AM   #6
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Quote:
Originally Posted by fatra2 View Post
Hi there,

I am not an expert on the question of keys and security, but I believe you can restore your keys, or create new ones, with
Code:
openssl
For the details on how to do so, you can search the web for example and more explanation.

Cheers
OP clearly asked about ssh keys, why would you lead them on a wild goose chase with OpenSSL? If you don't know what you're talking about, just leave the question alone and let someone else answer it (which colucix did).
 
Old 08-27-2008, 02:13 PM   #7
dmor
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks you all!

I will check the commands you gave me.

Your answers are great! I really appreciate it.

Thanks again!
 
Old 08-27-2008, 02:28 PM   #8
dmor
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Original Poster
Rep: Reputation: 15
So :-)

First of all, thanks again.

BUT, I must to ask about David1357's answer...

Why it's matter talk I have asked the question about PPK of SSH? Why I can solve the problem with SSH PPK and other public/private keys pairs I can't?

Thanks in advance.

Dmor.
 
Old 08-27-2008, 02:45 PM   #9
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by dmor View Post
Why it's matter talk I have asked the question about PPK of SSH? Why I can solve the problem with SSH PPK and other public/private keys pairs I can't?
ssh-keygen clearly creates a file that contains both the public and private keys (e.g. id_rsa). When you delete the public key (e.g. id_rsa.pub) you can extract another copy using "ssh-keygen -y".

On the other hand, imagine if someone could take your public key and derive your private key: they could read your messages and forge messages from you.
 
Old 08-27-2008, 02:49 PM   #10
dmor
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Original Poster
Rep: Reputation: 15
?

Thanks David.

You want to tell me that id_dsa for example contains the public key??? (the contents of id_dsa.pub)?

I always thought of it has the DELTA between them...

 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Public key, private key explained calande Linux - Security 3 06-12-2008 05:23 AM
need help with SSH private/public key taduser Linux - Security 2 04-02-2007 07:07 PM
SSH - trouble authenticating private/public key Micro420 Linux - Networking 5 01-23-2007 01:08 PM
public/private key authentication with PuTTY NetAX Linux - Security 5 10-27-2004 06:00 PM
RSA public key encryption/private key decription koningshoed Linux - Security 1 08-08-2002 07:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration