

#Hardcoded password password#
We then set a variable called REMOTE_PASSWD to the value of the decrypted password pulled from the “.secret_vault.txt” file, using the same command that we used a moment ago.We set a variable called REMOTE_USER to “geek.”.Sshpass -p $REMOTE_PASSWD ssh -T > /home/$REMOTE_USER/script.log # connect to the remote computer and put a timestamp in a file called script.log secret_vault.txt | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:'secret#vault!password') Our script is pretty straightforward: #!/bin/bash
#Hardcoded password how to#
RELATED: How to Use the chmod Command on Linux Using OpenSSL in a Script Using a permissions mask of 600 removes all access for anyone other than the file owner. We can now move on to writing our script. The encrypted version of our rusty!herring.pitshaft password is written to the terminal window.Ĭhmod 600. Substitute with a robust password of your choosing. -pass pass:’’: The password we’ll need to use to decrypt the encrypted remote password.


PBKDF2 requires many computations to perform the encryption.
#Hardcoded password install#
On Manjaro Linux, we can install OpenSSL with: sudo pacman -Sy opensslįinally, to install sshpass, use this command: sudo pacman -Sy sshpassīefore we get into using the openssl command with scripts, let’s become familiar with it by using it on the command line. Let’s say that the password for the account on the remote computer is rusty!herring.pitshaft. The command to install sshpass is: sudo dnf install sshpass On Fedora, you need to type: sudo dnf install openssl To install sshpass, use this command: sudo apt install sshpass On Ubuntu, type this command: sudo apt get openssl However, if it isn’t, it only takes a moment to install. RELATED: How to Create and Install SSH Keys From the Linux Shell Installing OpenSSL and sshpassīecause a lot of other encryption and security tools use OpenSSL, it might already be installed on your computer. We’re going to make use of the well-known OpenSSL toolkit to handle the encryption and a utility called sshpass to feed the password into the SSH command.
