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 1jnY7d-0008SF-Pz for pgsql-admin@arkaria.postgresql.org; Tue, 23 Jun 2020 01:53:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jnY7c-0003HW-N1 for pgsql-admin@arkaria.postgresql.org; Tue, 23 Jun 2020 01:53:12 +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 1jnY7c-0003HP-AA for pgsql-admin@lists.postgresql.org; Tue, 23 Jun 2020 01:53:12 +0000 Received: from mail-qv1-xf42.google.com ([2607:f8b0:4864:20::f42]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jnY7a-00061y-3U for pgsql-admin@lists.postgresql.org; Tue, 23 Jun 2020 01:53:11 +0000 Received: by mail-qv1-xf42.google.com with SMTP id a14so2657756qvq.6 for ; Mon, 22 Jun 2020 18:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=tl2HKs4NVKtitUyxpyZ2uFIYMof3nqITaE8xLlrGXhM=; b=Pa65oI7U82huW4eO5R17d5FxMGQJJfM3t9bRyKEZLIpEcU47UPiTQdweHtmUHM0/7u k+VDmvB13aB5HEzre/749sSwsbHJCLvUBf4VVq+XLe9bQl7PbvRCu/GqPyYu4OT4wQPe BS0g28z11Ta2flFqAecVP9CWSGuaXnKoDilsYcYAOeKMXvqBNv2n7HJjj2SeEiAuF6Dw c+IIRYvNuZvaOlSTFcpmZ0qNQoeMkmopoJQyVjIAyJrRuR2yhGMkjs5mEpzHav3kE7gG l6nB5OQGIyCN1R4NPcbhxfm3Ycd7m2WaQ2ylZAdy78UfFxerfcKhNnCLFgT8wx1XbAej AHyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=tl2HKs4NVKtitUyxpyZ2uFIYMof3nqITaE8xLlrGXhM=; b=kqaUmiLeUdTRXrNGm89esMHWiGWT7txusVBBYYLMy9MShY4r11qJkFF3gHstXDQFLW FfvRK4HSzN22NmyqN7E1ShWJYFO83DMorHB83HxV69Rnb0B4n8Q4nU4t6WoXSnFKIh42 x4kzkyiCAWjopvMdTFrCz/2xlg4aZEhY0kumGIPhH/j/zJjzQ7DFC28/rTUTdbRuYWi9 1toV+D8HgEYh+jqVwaIPsFAU7g6VIbmzd2DmgANJLY0/KReqsrQ7lOjvH3FN3OvjhN63 /n9u+ewEWVGuXJr3LoEMIRduSNCG3HiFOPr81zg8u7xD2rNsBQSez3EjeFx1dRoLS2LU 826w== X-Gm-Message-State: AOAM533nbGw4HqiUXbjz2c3aroxUCzAO29YInHd5dnjKR/Bgbe74LulU 9fyox+6PRO9pY7lAX8FF2D3KbA== X-Google-Smtp-Source: ABdhPJyPfbebxrFdnQYV3ZjLKeY97jAxJbboXomeMpk0NPx8rGPOL5fT4jkN3O7i1wZxf0K7nJ8kig== X-Received: by 2002:a0c:efcf:: with SMTP id a15mr24555798qvt.108.1592877189078; Mon, 22 Jun 2020 18:53:09 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id r76sm14552731qka.30.2020.06.22.18.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 18:53:08 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 2585D2A3A2C; Mon, 22 Jun 2020 21:53:06 -0400 (-04) Date: Mon, 22 Jun 2020 21:53:06 -0400 From: Alvaro Herrera To: Tim Cross Cc: pgsql-admin@lists.postgresql.org Subject: Re: scram-sha-256 encrypted password in pgpass Message-ID: <20200623015306.GA12369@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87mu4ud3vj.fsf@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Jun-23, Tim Cross wrote: > If you need to use a password in a command line scenario (i.e. with a > script), then one way to get around the issue of not storing plain text > passwords is to use GPG. The basic model is > > - Create a GPG key and store it in a secure place, such as a keystore > - Use that GPG key to encrypt your password in a file e.g. my-secret.gpg > - In your script, you can have something like > > PWD = `gpg -q --for-your-eyes-only --no-tty -d ~/.secure/my-secret.gpg` Perhaps the way to implement this is to have .pgpass be a named pipe, and you have a program that produces lines from encrypted input after requesting a passphrase from the user -- perhaps using gpg underneath. I have vague recollections of this being discussed in the past. For example, see this thread from 2013 https://www.postgresql.org/message-id/CAAZKuFaJUfdDFp1_vGHbDfYRu0Sj6mSOVvKRp87aCQ53ov6iwA@mail.gmail.com -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services