Justin
Justin

Reputation: 1479

Is my ssh key correct? It doesn't start with 'ssh-rsa' (Trying to set up private key validation, worried about being locked out of server)

I am trying to set up private key validation on my server. I think this is a simple question, I just don't want to get locked out of the server by mistake! I generated an ssh key with ssh-keygen. It is just a long list of characters as such :

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAA..etc
-----END OPENSSH PRIVATE KEY-----

However, the video I am watching on deployment shows an ssh key like such:

ssh-rsa b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAA..etc USER@desktop2FBF

I am not sure if they look different because I am on a mac and the guide is using windows. But my key does not begin with ssh-rsa or end with USER@... Also, I see there are two files created with this command, the .pub one I cannot open, so I assume I am copying and pasting the key from the right file(the only one I can open).

Thanks for any help.

Upvotes: 4

Views: 12476

Answers (3)

Manish Patil
Manish Patil

Reputation: 37

After creating token files, check clearly it comes with two files -

  1. one contains token like you shared
  2. Another file with different format it contains - rsa key, copy that one

Upvotes: 0

Chris Dodd
Chris Dodd

Reputation: 126526

ssh keys come in pairs -- a public key and a private key -- and that is what ssh-keygen creates, in two separate files. The file with the .pub extension is the public key, is generally smaller, and has the form you see on the video. The private key has the form you descibe with BEGIN PRIVATE KEY. They are intentionally very different so they don't get accidentally mixed up.

To use the key-pair, you will install the public key on the server, but you keep the private key private -- it never goes anywhere and is never copied; you just use it from your private machine to access the server(s) you've installed the public key on.

So in your case, you need to open the .pub file to get the public key and copy that to you server. The private key you keep local (possibly installing it into your ssh agent)

Upvotes: 6

Lucretius
Lucretius

Reputation: 23

Open the directory where you created the key.
There will be a file called [kleyname].pub, you will find something like this there [ssh-rsa b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAA..etc USER@desktop2FBF]

Upvotes: 0

Related Questions