Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Obtain public key given Private Key

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
banderas20
Posts: 111
Joined: 2016-11-10 15:30

Obtain public key given Private Key

#1 Post by banderas20 »

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: 111
Joined: 2016-11-10 15:30

Re: Obtain public key given Private Key

#3 Post by banderas20 »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Obtain public key given Private Key

#4 Post by debiman »

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
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Obtain public key given Private Key

#5 Post by GarryRicketson »

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.

banderas20
Posts: 111
Joined: 2016-11-10 15:30

Re: Obtain public key given Private Key

#6 Post by banderas20 »

[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!

cronoik
Posts: 310
Joined: 2015-05-20 21:17

Re: Obtain public key given Private Key

#7 Post by cronoik »

The following command gives you the public to a given privatekey:

Code: Select all

ssh-keygen -y -f privatekey
Have a nice day!

banderas20
Posts: 111
Joined: 2016-11-10 15:30

Re: Obtain public key given Private Key

#8 Post by banderas20 »

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!

cronoik
Posts: 310
Joined: 2015-05-20 21:17

Re: Obtain public key given Private Key

#9 Post by cronoik »

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!

Post Reply