1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>28.12.The Password File</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="libpq.html" title="Chapter28.libpq - C Library">
<link rel="prev" href="libpq-envars.html" title="28.11.Environment Variables">
<link rel="next" href="libpq-pgservice.html" title="28.13.The Connection Service File">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="libpq-pgpass"></a>28.12.The Password File</h2></div></div></div>
<a name="id686508"></a><a name="id686517"></a><p>The file <code class="filename">.pgpass</code> in a user's home directory or the
file referenced by <code class="envar">PGPASSFILE</code> can contain passwords to
be used if the connection requires a password (and no password has been
specified otherwise). On Microsoft Windows the file is named
<code class="filename">%APPDATA%\postgresql\pgpass.conf</code> (where
<code class="filename">%APPDATA%</code> refers to the Application Data subdirectory in
the user's profile).</p>
<p>This file should contain lines of the following format:
</p>
<pre class="synopsis"><em class="replaceable"><code>hostname</code></em>:<em class="replaceable"><code>port</code></em>:<em class="replaceable"><code>database</code></em>:<em class="replaceable"><code>username</code></em>:<em class="replaceable"><code>password</code></em></pre>
<p>
Each of the first four fields may be a literal value, or <code class="literal">*</code>,
which matches anything. The password field from the first line that matches the
current connection parameters will be used. (Therefore, put more-specific
entries first when you are using wildcards.)
If an entry needs to contain <code class="literal">:</code> or
<code class="literal">\</code>, escape this character with <code class="literal">\</code>.
A hostname of <code class="literal">localhost</code> matches both <code class="literal">host</code> (TCP)
and <code class="literal">local</code> (Unix domain socket) connections coming from the
local machine.</p>
<p>The permissions on <code class="filename">.pgpass</code> must disallow any
access to world or group; achieve this by the command
<code class="command">chmod 0600 ~/.pgpass</code>.
If the permissions are less strict than this, the file will be ignored.
(The file permissions are not currently checked on Microsoft Windows,
however.)</p>
</div></body>
</html>
|