Hide Your Shell Passwords with sshpass

Hard-coding is never the answer. Instead, use sshpass when you need to put a password in your Bash script.

At some point in your interactions with Linux, you will write a shell script, Bash or otherwise. It could be as simple as a single line or as complex as any program you’ve ever written. Either way, they help to make Linux the most flexible and powerful operating system on the planet.

The deeper you dive into shell scripting in Linux, you might run into a situation where you need to include a password in a script. When that happens, you certainly don’t want to hard-code that password.

Or, if you wind up getting prompted for the password, you can’t automate the script. Anyone who gains access to your machine could view that script and then have access to whatever account that password is associated with. Also, cron jobs for that script will fail.

For example, you might create a backup script that uses rsync over a network and requires a user password for security purposes. Say, for example, you have the /data directory which houses specific information for which you need to have a regular backup. You’ve set it up such that it has all the necessary permissions and the last thing to do is create a backup that will save the contents to a remote machine.

Read More Here.


Discover more from Vancouver Linux Users Group

Subscribe to get the latest posts sent to your email.


Posted

in

by

Discover more from Vancouver Linux Users Group

Subscribe now to keep reading and get access to the full archive.

Continue reading