I want to execute a command on a remote server (Cent OS 7) and use the environment variables defined on that server. However, when I run this command
ssh myuser@remotehost.com "PGPASSWORD=$DB_PASS psql -U $DB_USER -d $DB_NAME -c 'COPY myapp_currencyprice to STDOUT WITH (DELIMITER \",\", FORMAT CSV, HEADER)' > /tmp/prices.csv"
it seems the command is trying to use "$DB_PASS" and other env vars from the localhost instead of from "remotehost.com". What's the proper way to reference env vars from the remote server?