Encrypting data with a public key and then decrypting it with a private key is called encryption and decryption.
Private key encrypts data, and public key decryption is generally called signature and verification signature.
RSA/DSA
The universal public key will not be transmitted to others in plain text. Normally, a file is generated. This file is a public key file, and then this file can be given to others for encryption. But if someone maliciously destroys it during the transmission, you can change your public key into his public key, and then get the encrypted data of the public key party. Can't he decrypt the data with his own key? In order to solve this problem, a notary is needed to do it. Anyone can find it to confirm who sent the public key. This is CA, and the principle of CA confirming public key is also very simple. It publishes its public key to everyone, and then a person who wants to publish his public key can send his public key and some identity information to CA, and CA encrypts it with his own key. This can also be called a signature. Then this file containing your public key and your information can be called a certificate file. In this way, everyone who gets some public key files decrypts the files through CA's public key. If it is decrypted normally, the information in the secret must be true, because the encryption party can only be CA, and no one else has its key. In this way, you can unlock the public key file and see if the information inside is the public key you need to encrypt.
The format of the key file generated by OpenSSL is only PEM and DER.
The key of PEM is represented by base64 code. Open it directly and you can see a string of English letters.
DER format is a binary key file.
Reference: Website
Regardless of the environment, you can use the following command to generate a new ssh key:
After selecting the generated file and key password, two files will be generated, among which the * * * key with pub suffix.
The default location of SSH is:
Windows command prompt:
Git Bash on windows/GNU/Linux/macos/powershell:
Reference: gitlab.com