Skip to content

Cryptography

1. Create a public/private key pair.

The ssh-keygen tool is used to generate the key pair with this command

/home/ubuntu/.shh/id_ed25519_test_one
ls -l .ssh

Running this command creates two files: a private key and a public key. The Public Key (.pub): This file ends with .pub and is safe to share with platforms you want to access (like GitHub or a remote server).

The Private Key (No extension): This file has no file extension. It stays strictly on your local system. It must never be shared. If someone gets your private key, it is exactly like giving them a physical key to your home.*

Another way of making a Key Pair

I have generated a dedicated key pair. Following best practices, these keys will be stored locally within the hidden ~/.ssh directory. I ran the following command on my ubuuntu Virtualbox

ssh-keygen -t ed25519 -f ~/.ssh/myclass_id -C "cyberclass-norbu"

Then check your keys: ( ls -l ~/.ssh ) The .ssh directory now contains both files: the private key (myclass_id) and the public key (myclass_id.pub).

In my .ssh directory listing:

  • Private key should be kept secret and never shared.
  • id_ed25519_test_one.pub → This is my public key. This file can be shared freely. You place it in the authorized_keys file on servers you want to access. authorized_keys → This file on the server contains public keys of clients allowed to connect. I came to know that the file without .pub is the private key and the file with .pub is the public key.

What is the public key?

A public key is a cryptographic key that can be shared with anyone. It is used to encrypt data or verify a digital signature. I can safely share with a server. ( SSH servers, Git servers, Cloud systems, etc…) Private key stays only on your computer, proves you own the account and creates authentication signatures

What is the private key?

A private key is a secret key that only the owner should know. The server never receives your private key. It is used to decrypt data that was encrypted with the public key or to create digital signatures.

What can this key pair be used for?

A public and private key pair is used in: Secure communication (like SSH or HTTPS) Encrypting and decrypting messages Logging into servers securely (SSH authentication) Digital signatures (to verify identity and data integrity)

Why must the private key be protected?

The private key must be kept secret because: Anyone who gets it can access your accounts or data They could pretend to be you (identity theft) They could decrypt your secure messages So, losing or exposing it breaks the security system completely.