Is there an equivalent of .ssh/config for use with psql?

Posted on

Problem :

In the .ssh/config file (at least that’s the usual default location), I can define hostname, username, port, etc. for ssh connections and store it with an easy to use name. That allows me to call ssh or scp without having to do all the tedious typing, but just hit e.g. ssh myconnection2.

Is there an equivalent for this functionality in psql? The man page mentions the .psqlrc file in terms of configuration, which is not quite what I need, because it’s sourced only after psql is started.

The only halfway decent workaround I have so far is to use alias, but that comes with problems of its own in some cases. Any ideas if I’m missing something?

Solution :

Found a solution, the connection service file: https://www.postgresql.org/docs/current/libpq-pgservice.html