Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hzkl1-0000zM-Sq for pgsql-general@arkaria.postgresql.org; Mon, 19 Aug 2019 16:43:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hzkl0-0000Ns-EM for pgsql-general@arkaria.postgresql.org; Mon, 19 Aug 2019 16:43:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hzkkz-0000C8-4v for pgsql-general@lists.postgresql.org; Mon, 19 Aug 2019 16:43:46 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hzkkw-0003sR-2c for pgsql-general@lists.postgresql.org; Mon, 19 Aug 2019 16:43:43 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 54EC522022; Mon, 19 Aug 2019 12:43:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 19 Aug 2019 12:43:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=0 HTDWqlgkHsSeGdBRrattBYYTvBtGtluav79Ls/aKs8=; b=fZXPQG5ARPsLacEbx t9dVvMm7n/ign2aobZpsJgFz2q3ZmXeOJqxeXmZv4DTR0+a1j3aO+yBvd1IJYHCQ eecV9MzR3ScjDX4acCHB5AVVEjBOaKw3BJ5gFh2KE1p0bb58emXlcrD1j1d5VX+O HazWS7NC6HoVdKSGcm/wi19hgneHUXmoOttZn0ZZx988yjSo96P6dbU5XnHp0GEG pX7/RpgJNPL4JpdhLYNLFXI0esKCMKVRdEVt8WGbUFu+2b+cvaslxvBxCxespuX7 Goh4dU2eNZd31FbPXgSs2FQzW0TSoCgH2P+D01+lHapplUznc8h8A08Ok+2+3d/6 9FwqQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=0HTDWqlgkHsSeGdBRrattBYYTvBtGtluav79Ls/aK s8=; b=UnGM3FPw+qXQ6v+NqmocTuNpS5xck+sVPizXwqJnRZBLsUkzfkbJgpOKT q7KadYKwsxcaY1IhLXRWNSTrqwQ2+V0w/zsofObQko31yrT4Aq4euaFTo8fe2fxq tOphHhmbwWJ/eu0JsYqj4o+01ddbrO9lJMbmYfiay0KntEfXVKeO9wjiaRyv8CGP iYAsHHu03Dj3NrqmuefJuAgiJfljrC6HFmsA1Ap+sLwjr2jMd72UlTzRegNvSD4e Y+7vLD9cyPXwJDTj27o80aux/z03ZpLqPO/+88tavNFOTZQqmOZG6JAiAfR/a0pm KbWz/sgFZbeOa+i5ettN1qmrBPT/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudefledguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvg hsqhhlrdhorhhgnecukfhppeejgedrleegrdejfedrvddvvdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id 691E238008D; Mon, 19 Aug 2019 12:43:30 -0400 (EDT) Subject: Re: Sorry, real newbie question about connecting to a database To: stan , pgsql-general@lists.postgresql.org References: <20190819144445.GA7984@panix.com> From: Adrian Klaver Message-ID: <4d14ec8e-6160-898c-718f-2a2b80b072c5@aklaver.com> Date: Mon, 19 Aug 2019 09:43:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190819144445.GA7984@panix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/19/19 7:44 AM, stan wrote: > I am developinng an appliction usig Postgresql 11, installed on a UBUTU > 18.14 machine. > > I ahve vreated a new database to do some testing on restricting access of > specific users/roles to certain data. I have done the following: > > REVOKE ALL ON DATABASE pertest FROM employee; > GRANT CONNECT ON DATABASE pertest TO employee; > > and I have verifed tht the user employee does exst, I have also doen a few > more GRABTs to allow specific acces. But I cannot conect, or swith to user > employee: > > stan@smokey:/etc/postgresql/11/main$ psql -U employee > psql: FATAL: Peer authentication failed for user "employee" > > stan=> \l > List of databases > Name | Owner | Encoding | Collate | Ctype | Access privileges > --------+----------+----------+---------+---------+----------------------- > pertest | stan | UTF8 | C.UTF-8 > | C.UTF-8 | =Tc/stan + > | | stan=CTc/stan > > employee=CTc/stan > > Sorrry cut and paste mangled that. > > What am I failing to do here? > > Tom has spelled out the specific issue. The generic issue is that security in Postgres is a multi-layer process that involves many moving parts. You will save yourself a lot of do overs by looking at the relevant documentation. Starting roughly from outside in: Server connection: https://www.postgresql.org/docs/11/runtime-config-connection.html Client authentication(the pg_hba.conf Tom referred to): https://www.postgresql.org/docs/11/client-authentication.html Database roles(users): https://www.postgresql.org/docs/11/user-manag.html Role/user permissions: https://www.postgresql.org/docs/11/sql-grant.html Finer grained permissions(row level security): https://www.postgresql.org/docs/11/ddl-rowsecurity.html The above is intimidating and not something that will be fully understood in a single reading(or in my case multiple readings:)). Still a passing familiarity with the concepts will make your life easier. -- Adrian Klaver adrian.klaver@aklaver.com