Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTMZv-00055t-Ft for pgsql-general@arkaria.postgresql.org; Mon, 05 Apr 2021 10:35:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lTMZu-0007Pb-5C for pgsql-general@arkaria.postgresql.org; Mon, 05 Apr 2021 10:35:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTGid-0005Yz-UX for pgsql-general@lists.postgresql.org; Mon, 05 Apr 2021 04:20:07 +0000 Received: from mr85p00im-ztdg06011201.me.com ([17.58.23.181]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTGia-0000KQ-1O for pgsql-general@postgresql.org; Mon, 05 Apr 2021 04:20:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1617596401; bh=dbXSbxyv/RaV8Hf4WIjkYp0MZpTSYBF1smNwo/vNwEw=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:To; b=XfxN0VXKXnWbcvK6nt69c18+q3i18jSjZmfzwWRki++LukIrMtv9fBg09TFYdWsl6 kORcntHtUN3yCq47rL4bcZPm+yfxVUu6fYy6qAbiJXbq4PrlcUN0ks3NtSWJXyF1bA NmKo6hU/u43c+AL2umVSPtpaHd7kwGoklkZoyiRhzFfdu1E28OJWQKGeNhN4+QIjo8 7lGpJ2ad4azbNUs8BmJ49e1u4ixKGbLTkYnn4Zg3fSJLTplLL/IXjpC8jON+C+d4UN fMMBEyqBUO/71Rt7tLx7JlK7xnn1sC6H+Zi78nEq3CQU5lLTd+uyHREbN40pr24MW/ tZVR7c3oKawqQ== Received: from [192.168.1.145] (047-045-088-016.biz.spectrum.com [47.45.88.16]) by mr85p00im-ztdg06011201.me.com (Postfix) with ESMTPSA id 347D84006A8; Mon, 5 Apr 2021 04:20:01 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: "A. Reichstadt" Mime-Version: 1.0 (1.0) Subject: Re: How to deny access to Postgres when connected from host/non-local Date: Sun, 4 Apr 2021 21:20:01 -0700 Message-Id: <91D3E0F2-032F-4166-A53A-9D26AA981CC7@me.com> References: Cc: pgsql-general@postgresql.org In-Reply-To: To: Joe Conway X-Mailer: iPhone Mail (18D61) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-04-05_02:2021-04-01,2021-04-05 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2006250000 definitions=main-2104050028 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks, works. Sent from my iPhone > On Apr 3, 2021, at 11:02, Joe Conway wrote: >=20 > =EF=BB=BFOn 4/2/21 7:06 PM, A. Reichstadt wrote: >> Hello, >> I try to deny access to all databases on my server if the user =E2=80=9Cp= ostgres" tries to connect from a non-local host. Here is what I did in pg_hb= a.conf: >> # TYPE DATABASE USER ADDRESS METHOD >> # "local" is for Unix domain socket connections only >> local all all md5 >> # IPv4 local connections: >> host all all 127.0.0.1/32 md5 >> # IPv6 local connections: >> host all all ::1/128 md5 >> # Allow replication connections from localhost, by a user with the >> # replication privilege. >> local replication all md5 >> host replication all 127.0.0.1/32 md5 >> host replication all ::1/128 md5 >> host all all 0.0.0.0/0 md5 >> local all postgres trust >> host all postgres 0.0.0.0/0 reject >> But it continues to allow for Postgres to connect from anywhere through P= GAdmin but also as a direct connection to port 5432. I also relaunched the s= erver. This is version 12. >> What else do I have to do? >> Thanks for any help. >=20 > See: > https://www.postgresql.org/docs/13/auth-pg-hba-conf.html >=20 > In particular: >=20 > "Each record specifies a connection type, a client IP > address range (if relevant for the connection type), > a database name, a user name, and the authentication > method to be used for connections matching these > parameters. The first record with a matching > connection type, client address, requested database, > and user name is used to perform authentication." >=20 > So your reject line is never being reached. >=20 > HTH, >=20 > Joe >=20 > --=20 > Crunchy Data - http://crunchydata.com > PostgreSQL Support for Secure Enterprises > Consulting, Training, & Open Source Development