6

I was given a public ssh key, user name, and host name to access a server. I have found a lot about using public key ssh authentication, and all the tutorials I find start with execute this command: ssh-keygen -t rsa. But how do I do it when I am given a public key? I don't know how to incorporate the public key into the tutorials I have read.

Here is an example of what I was given:

ssh-rsa AAA...(more)...Y0kQ== [email protected]

2 Answers 2

11

You cannot log in to a SSH server using a public key, only using a private key. The server has to know the corresponding public key in order to let you in. So what you'll need to do is to send them your public key (which is generated when you do the ssh-keygen -t rsa).

5
  • 3
    As an addage to that: the public key ends in .pub, by default. Keep your private key just that, private, like you would any password, and never give it to anyone.
    – Xyon
    Jan 29, 2013 at 13:43
  • Thanks, this makes sense. Why was I given this information then? I can't do anything with it?
    – Ryan
    Jan 29, 2013 at 13:48
  • Well, no. A public key without the private key is only useful for giving someone else access to your system. So you could let the other party log on to your computer/server. Probably not what you want. It's likely they just don't know how this works. Jan 29, 2013 at 13:53
  • 1
    @I3v: The person whom send you the public key is most likely following the wrong instructions for giving you access, he should expect you to send a public key he can add and not the other way around. Jan 29, 2013 at 13:53
  • 2
    Weird that it seems to be the opposite of what should have happened. Thanks everyone.
    – Ryan
    Jan 29, 2013 at 14:03
3

This is not how SSH works, here is the standard procedure:

  1. You generate your private and public key.
  2. You send your public key, you don't send the private key.
  3. Once they have add your public key you have access.

If you don't have a private key to go along with the public key then you can't use that public key since you don't have the corresponding private key. This private key needs to be generated by yourself and never shared, since anyone else that has this private key can access the server under your name.

It is likely they don't know how SSH works, they should expect you send them a public key.


As to why this does work the way this does, let me explain...

Take the second image here from an informational page at Amherst College for example, the top part of this image is the server and the bottom part of this image is the client. The server encrypts the messages using the public key and then it can only be decrypted using the private key.

Therefore, for successful communication you need the private key as well. And for secure communication, you don't share that key with anyone as they will be able to read your messages.

1
  • Link was helpful.
    – Ryan
    Jan 29, 2013 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .