Each person has a pair of keys , and publishes that in a directory which everyone can see, and they keep their private key on their system.
If A wants to send a message to B, they look up B's public key in the directory and then encrypt their plaintext message using it to produce the ciphertext.
In order to decipher the message, one has to decrypt it using B's private key which means that no-one else can read messages intended for B.
Suppose you want to allow someone to send you a message on your computer securely using the RSA protocol, then you do the following: