Skip to main content
Question

How do I handle the password in vsql command in crontab?

  • March 24, 2020
  • 3 replies
  • 15 views

Prairiedog

I want to schedule a shell script that kicks off a vSQL command from a crontab. I cannot leave an open password in the file and I cannot answer a password prompt when the job kicks off a midnight on a weekend. So how does one use the username to map to the acceptable password to get through the server firewall?

3 replies

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • March 26, 2020

If you have the vsql password in the environment variable VSQL_PASSWORD, it works.
Of course, there's a risk in putting:
export VSQL_PASSWORD='<dbadmin_s_password>' into the OS user's .bash_profile or similar.
But there's a collection of tools out there that store an encrypted password somewhere and decrypt it on the fly to put it into a shell variable. Worth exploring ...


SergeB
Forum|alt.badge.img
  • Participating Frequently
  • March 30, 2020

If suitable in your environment,, another solution is to have a passwordless authentication method (TRUST, TLS with self-authentication or Kerberos)


ChuckB
Forum|alt.badge.img
  • Participating Frequently
  • March 31, 2020

In addition to what others said, you can use the -w option on the vsql command line to set the password, but from a security perspective that's probably the worst because command lines are frequently visible / logged in places anyone on the machine can see. Investigating other security options makes sense here, as Serge mentioned.