Created
March 28, 2024 03:40
-
-
Save Lantianyou/278d1a8507bc6e44a1f9747d64fba36b to your computer and use it in GitHub Desktop.
ssh.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#生成公钥私钥对 | |
openssl genpkey -algorithm RSA -out private_key.pem | |
openssl rsa -pubout -in private_key.pem -out public_key.pem | |
#将公钥分享给其他人,私钥自己保存 | |
#其他人用公钥加密信息,然后发给你,你用私钥解密信息 | |
#用公钥加密信息,plaintext.txt 是要加密的文件,encrypted.txt 是加密后的文件 | |
openssl pkeyutl -encrypt -pubin -inkey public_key.pem -in plaintext.txt -out encrypted.txt | |
#用私钥解密信息,encrypted.txt 是加密后的文件,decrypted.txt 是解密后的文件 | |
openssl pkeyutl -decrypt -inkey private_key.pem -in encrypted.txt -out decrypted.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment