Obtain public key given Private Key

Kernels & Hardware, configuring network, installing services

Obtain public key given Private Key

Postby banderas20 » 2018-07-02 16:34

Hello,

I need to be able to authenticate against a Debian server with an specific private Key (format ed25519).

¿Is there any way to create the corresponding public key? ¿how?

Thanks!
banderas20
 
Posts: 107
Joined: 2016-11-10 15:30


Re: Obtain public key given Private Key

Postby banderas20 » 2018-07-03 04:52

debiman wrote:http://xyproblem.info/


I have private key X. I want to get the corresponding public key Y (both in format ed25519) by using ssh-keygen or other software.
¿Is that possible? If so, ¿how?

I think I have been clear enough from the beginning. Else, ask for what you need.
banderas20
 
Posts: 107
Joined: 2016-11-10 15:30

Re: Obtain public key given Private Key

Postby debiman » 2018-07-03 15:05

why do you think you need that?
why do you think "you can fumble your way to a solution if you can just manage to do" that?
should i quote the rest of that text back to you, too?

what is really the problem here?
User avatar
debiman
 
Posts: 2814
Joined: 2013-03-12 07:18

Re: Obtain public key given Private Key

Postby GarryRicketson » 2018-07-03 16:47

by banderas20 » ¿Is that possible? If so, ¿how?

If the server is yours, or you are the authorized administrator, you probably can,
so it is possible. How ? I am not sure, but if it was me I would do this:
How to get a public key by using ssh-keygen or other software on a Debian server

If it is not your server, then you would need to contact the system admin of the server, and ask them to give you a public key, there is not guarantee they will though.
It might help you to also do a search and read about the difference between a public key and a private key. Keywords:
Code: Select all
On a Debian server, what is the difference between public and private keys

The first hit in the search results,
https://www.ssh.com/ssh/keygen/
Did you even try to search for a answer to this ?
Further down , about the 6th hit:
https://www.debian.org/devel/passwordlessssh
Run ssh-keygen(1) on your machine, and just hit enter when asked for a password.
This will generate both a private and a public key. With older SSH versions, they will be stored in ~/.ssh/identity and ~/.ssh/identity.pub; with newer ones, they will be stored in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub.

From another hit:
Using ssh keys

All you have to do is:

generate a pair of keys with ssh-keygen. This will create two files: a public key (normally .pub), and a private key. The private key is normally kept encrypted on disk. After all, it's well, supposed to be private. ssh-keygen will ask you to insert a password. Note that this password will be used to decrypt this file from your local disk, and never sent to anyone. And again, as the name suggest, you should never ever disclose your private key.

copy your public key into any system you need to have access to. You can use rsync, scp, type it manually, or well, use the tool provided with openssh: ssh-copy-id. Note that you could even publish your public key online: there is no (known) way to go from a public key to your private key and to get access to any of your systems. And if there was a way, well, public key encryption would be dead, and your bank account likely empty.

So any way, it is not like there is no information on this, or nobody has ever done this before,...all you need to do is read some of the material in the search results.
User avatar
GarryRicketson
 
Posts: 5051
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Obtain public key given Private Key

Postby banderas20 » 2018-07-05 14:59

[quote="GarryRicketson"]
Yes. The server is mine. I have been asked to provide access with a given private key. It's an exercise. A Proof of Concept.

I'll try your solutions. I thought it would be easier.

Thanks and regards!
banderas20
 
Posts: 107
Joined: 2016-11-10 15:30

Re: Obtain public key given Private Key

Postby cronoik » 2018-07-05 16:30

The following command gives you the public to a given privatekey:
Code: Select all
ssh-keygen -y -f privatekey
Have a nice day!
cronoik
 
Posts: 269
Joined: 2015-05-20 21:17

Re: Obtain public key given Private Key

Postby banderas20 » 2018-07-06 05:19

cronoik wrote:The following command gives you the public to a given privatekey:
Code: Select all
ssh-keygen -y -f privatekey


I never thought it was going to be so easy.

BTW, When I run the command, it prompts me for a passphrase. I enter anything and it says "incorrect passphrase supplied to decrypt private key".

For the record, the private key is in the format
Code: Select all
ssh-ed25519
AAAA..................


and I generated the file by opening an editor and copying and pasting its contents.

Thanks!
banderas20
 
Posts: 107
Joined: 2016-11-10 15:30

Re: Obtain public key given Private Key

Postby cronoik » 2018-07-07 11:48

banderas20 wrote:...BTW, When I run the command, it prompts me for a passphrase. I enter anything and it says "incorrect passphrase supplied to decrypt private key".

For the record, the private key is in the format

Code: Select all
ssh-ed25519
AAAA..................



and I generated the file by opening an editor and copying and pasting its contents.
A passphrase is something like a password. Without the correct passphrase you will not be able to get the private key and without the private key you will not be able to get the public key that belongs to your private key. You have two options now. When you need to use this key, ask the person that have gave you the key for the passphrase. In case it doesn't matters and you need just some ed25519 key, just generate a new one with:
Code: Select all
ssh-keygen -t ed25519
Have a nice day!
cronoik
 
Posts: 269
Joined: 2015-05-20 21:17


Return to System configuration

Who is online

Users browsing this forum: 1885 and 2 guests

fashionable