[ ssh ] Public key vs. Private key

How they work

keys

If you generate key with the command sshkeygen -t rsa, you will get two types of key.

Public key is for encrypting and private key is for decrypting. Which one do you think more important? Yes, of course private key. You can provide your public key to others to communicate. So, other people will use the public key to encrypt the file to send.

However, you are the only one who have a private key. That means you are the only one person who can decrypt the files. This is how the public key and private key work. 

  • Example
    • For Git, you need to copy your public key and paste it on the git site before use.
    • So if you pull repositories from Git, the server encrypts the repositories with your public key before sending.

Leave A Comment

Your email address will not be published. Required fields are marked *