I am trying to cron a simple 4 line bash script to backup a folder which requires me to mount the NAS folder for which I have to provide the password. Which is a big NO , Is there a way to pass the password in encrypted form or atleast a safe way.

I am trying to mount a NAS folder which requires the password, how to encrypt or make it secure.

sudo rsync -arltvu --progress /media/VAULT/Pictures/ /media/Pictures/  -o username=admin,pass=passphrase
  • Are you concerned about storing the login & password in plain text on your computer, or about sending them over the internet un-encrypted? – Xen2050 Dec 4 '15 at 14:53

How about replacing "passphrase" with "$(mypassphrase)", to run the program/script mypassphrase for providing the pass phrase at the run time of the cron command line.

  • So mypassphrase would ask you to type in the passphrase, and repeat it on stdout? I think I read about some ways stdin & stdout can be overheard by other programs/users, but on a single user ubuntu machine it's probably pretty secure – Xen2050 Dec 3 '15 at 10:16
  • If the NAS requires username and password on the rsync command, then there's no hiding of the password; it'll be available in /proc for the process, although you'd need to be root to access it of course. I merely imagined a "mypassphrase" program that picked up the password from somewhere safer; just avoiding it be in clear text in crontab. – Ralph Rönnquist Dec 3 '15 at 22:39

Having never used rysnc, I can't say for sure that this will work, but I would try using a credentials file (the following is summarized from this link).

Create a file called .nascredentials containing


and having the appropriate permissions (600 suggested).

Pass credentials=/path/to/.nascredentials instead of username=admin,pass=passphrase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.