$HOME/.pgpass is a file that can contain passwords to be used if the connection requires a password. This file should have the format:
hostname:port:database:username:password
Any of these may be a literal name, or *, which matches anything. The first match will be used so put more specific entries first. Entries with : or \ should be escaped with \.