title: How to connect pgAdmin III (Windows) to postgresql (Linux in virtual box)
body: <p>I have a <code>postgresql</code> demon on my virtual Linux box, and just installed pgAdmin III on the Windows machine. Now I'd like to configure the first connection.</p>
  
  <p>What I did so far:</p>
  
  <ul>
  <li>I edited <code>/etc/postgresql/9.1/main/pg_hba.conf</code> and added a line to make the demon accept connections from my Windows machine:<br>
  <code>host  all  all  192.168.123.45/32  md5</code></li>
  <li>I set a shell passphrase for the system user <code>postgres</code> (<code>sudo passwd postgres</code>)</li>
  <li><strong>Edit: this seems to be irrelevant</strong><br>
  I copied <code>/usr/share/postgresql/9.1/pg_service.conf.sample</code> to <code>/etc/postgresql-common/pg_service.conf</code> and uncommented the sample service, giving me<br>
  [postgres]<br>
  dbname=postgres<br>
  user=postgres</li>
  <li><strong>Edit: this seems to be irrelevant</strong><br>
  I put a line into <code>/etc/environment</code> to point to the <code>pgservice.conf</code> file:<br>
  <code>PGSERVICEFILE=/etc/postgresql-common/pg_service.conf</code><br>
  (which works; when I duplicated the PuTTY session, it had this variable)</li>
  <li>I restarted the database server after each change:<br>
  <code>sudo /etc/init.d/postgresql restart</code></li>
  <li>Finally, I restartet the Linux box,</li>
  </ul>
  
  <p>The server seems to have restarted successfully:</p>
  
  <pre><code>[ ok ] Restarting PostgreSQL 9.1 database server: main.
  </code></pre>
  
  <p>However, when I try to connect to the service, pgAdmin III gives me an error message:<br>
  Error connecting to the server: definition of service "postgres" not found.</p>
  
  <p><code>dmesg | grep postgres</code> gives me a single line:</p>
  
  <pre><code>[   18.054965] postgres (2242): /proc/2242/oom_adj is deprecated, please use /proc/2242/oom_score_adj instead.
  </code></pre>
  
  <p>I have no clue whether <code>postgresql</code> uses my <code>pq_service.conf</code> at all, or whatever else is the problem; any help is appreciated ...</p>
  
  <p><strong>Edit:</strong>
  My original question, "<code>How can I know whether postgresql uses my pg_service.conf file?</code>", seems to be answered - it simply doesn't.  I still can't connect; but now the question doesn't match the error messages anymore.</p>
  
  <p>I removed the "Service" entry from my "New Server Registration" data. Now I get another error - something like "password authentication for user >>postgres&lt;&lt; failed". I'm quite sure the password is correct - I just set it ... and I tested it by commenting out my ssh key from the <code>authorized_keys</code> file.</p>
  
  <p>I'd happily connect with my ssh key, but this seems to be difficult as well.  With PuTTY, my key is taken from Pageant, and I'm logged in without any problem; pgAdmin talks about "SSH tunnelling", but I normally don't need tunnels for this local machine ...</p>
  
  <p>I tried to create a tunnel anyway.</p>
  
  <ul>
  <li>PuTTY session:
  <ul>
  <li>Source port is <code>5432</code></li>
  <li>destination is <code>my-vbox.host.name:5432</code></li>
  </ul></li>
  <li>In pgAdmin, "SSH Tunnel":
  <ul>
  <li>Username <code>postgres</code></li>
  <li>using Identity file</li>
  <li>Tunnel host <code>localhost</code> &rarr; error:<br>
  "<code>SSH error: Could not connect to socket with error code 10051</code>"</li>
  <li>Tunnel host <code>localhost:5432</code> &rarr; error:<br>
  "<code>SSH error: Unable to resolve host: localhost:5432</code>"</li>
  <li>Tunnel host <code>127.0.0.1:5432</code> &rarr; error:<br>
  "<code>SSH error: Unable to resolve host: 127.0.0.1:5432</code>"</li>
  </ul></li>
  </ul>
  
  <p>How the heck is this supposed to be configured?!</p>