Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enter Multiple entries in .pgpass file?

I am supposed to execute same psql command from a bash script on 5 remote machines using a username and password.

I have read that we have to pass the credentials in .pgpass file and use the -w option while executing the psql command.

But how can I execute the same command on the 5 machines using the same .pgpass file?

like image 569
Hardik Kamdar Avatar asked Sep 30 '15 05:09

Hardik Kamdar


1 Answers

You can add multiple entries in .pgpass file for e.g.

syntax:

hostname:port:database:username:password

sample file:

test.net:5432:testdb:testuser:testpass
test1.net:5432:testdb1:testuser1:testpass1
test2.net:5432:testdb2:testuser2:testpass2

Make sure the permission of .pgpass file is set to 0600

chmod 0600 .pgpass
like image 186
abhish_gl Avatar answered Sep 27 '22 00:09

abhish_gl