An easy way to encrypt and decrypt large files using OpenSSL and Linux:
Generate PEM public private key using openssl:
We can generate hash using md5sum for both files so we can compare them once we decrypt our file:
Decrypt large file using OpenSSL:
Check md5sum output:
#linux #openssl #pem #encryption #decryption #x509 #public_key #private_key
Generate PEM public private key using openssl:
openssl req -x509 -nodes -newkey rsa:2048 -keyout private-key.pem -out public-key.pemEncrypt file using public key PEM file:
openssl smime -encrypt -binary -aes-256-cbc -in large_file.img -out large_file.img.dat -outform DER public-key.pem
We can generate hash using md5sum for both files so we can compare them once we decrypt our file:
md5sum large_file.img*
#cd573cfaace07e7949bc0c46028904ff large_file.img
#c4d8f1e868d1176d8aa5363b0bdf8e7c large_file.img.dat
Decrypt large file using OpenSSL:
openssl smime -decrypt -in large_file.img.dat -binary -inform DEM -inkey private-key.pem -out decrypted_large_file.img
Check md5sum output:
md5sum *large_file.img*
#cd573cfaace07e7949bc0c46028904ff decrypted_large_file.img
#cd573cfaace07e7949bc0c46028904ff large_file.img
#c4d8f1e868d1176d8aa5363b0bdf8e7c large_file.img.dat
#linux #openssl #pem #encryption #decryption #x509 #public_key #private_key
You can login to a server without entering a password by a simple command as below:
By issuing the above command it puts your public key content on server
#linux #sysadmin #ssh #passwordless_login #ssh_copy_id #authorized_keys #public_key
ssh-copy-id USERNAME@YOUR_HOST_IP -p 22
By issuing the above command it puts your public key content on server
~/.ssh/authorized_keys
and prompts you to enter the password. You are all done by this.#linux #sysadmin #ssh #passwordless_login #ssh_copy_id #authorized_keys #public_key