I have a spring app that is happily running on a staging and a prod server. It's time to automate deployments.
I have a restart.sh
script on my staging server. if I ssh
into the server and run it as a user everything works as expected.
command to run: nohup ./restart.sh
# restart.sh
kill $(ps -aux | grep plenti-app | grep java | awk '{print $2}')
java -jar -Dspring.profiles.active=staging plenti-app
However, when I attempt to run the command through ssh, it fails saying that password authentication for my database fails.
ssh user@$STAGING_IP "./restart.sh"
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "gszbybjk"
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:520) ~[postgresql-42.2.9.jar!/:42.2.9]
I first suspected that this might have to do with environment variables since that's how I'm storing the database credentials, but ssh calls to ssh user@ip echo $DB_PASSWORD
result in the expected value.