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 1kCuOD-0007PV-K4 for pgsql-docs@arkaria.postgresql.org; Tue, 01 Sep 2020 00:43:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kCuOB-0003kN-7l for pgsql-docs@arkaria.postgresql.org; Tue, 01 Sep 2020 00:43:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kCuOB-0003kG-1h for pgsql-docs@lists.postgresql.org; Tue, 01 Sep 2020 00:43:07 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kCuO3-00079y-U6 for pgsql-docs@lists.postgresql.org; Tue, 01 Sep 2020 00:43:06 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1kCuO1-0006aQ-Ap; Mon, 31 Aug 2020 20:42:57 -0400 Date: Mon, 31 Aug 2020 20:42:57 -0400 From: Bruce Momjian To: "David G. Johnston" Cc: Tom Lane , karimelghazouly@gmail.com, Pg Docs Subject: Re: small clairifcation Message-ID: <20200901004257.GU13613@momjian.us> References: <159854511172.24991.4373145230066586863@wrigleys.postgresql.org> <3379769.1598577411@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tThc/1wpZn/ma/RB" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Aug 27, 2020 at 09:51:49PM -0700, David G. Johnston wrote: > On Thu, Aug 27, 2020 at 6:17 PM Tom Lane wrote: > > PG Doc comments form writes: > > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/9.5/ssh-tunnels.html > > Description: > > > "The first number in the -L argument, 63333, is the port number of your > end > > of the tunnel; it can be any unused port. (IANA reserves ports 49152 > through > > 65535 for private use.) The second number, 5432, is the remote end of the > > tunnel: the port number your server is using. " > > > as a beginner This took me some time to understand what do you mean by > "your > > server" "your end of the tunnel " > > Hm, do you have a suggestion for better wording? > > > > I agree on the need for a different perspective here since it reads just fine > once you know what it is talking about. > > But absent that maybe a slightly more tutorial flow would be good. I didn't think a tutorial flow was the right thing to here, so I reworded the section to be more details and have a clearer flow --- patch attached. -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --tThc/1wpZn/ma/RB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ssh.diff" diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 6cda39f3ab..bc68ddc94b 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -2548,34 +2548,39 @@ openssl x509 -req -in server.csr -text -days 365 \ First make sure that an SSH server is running properly on the same machine as the PostgreSQL server and that you can log in using - ssh as some user. Then you can establish a secure - tunnel with a command like this from the client machine: + ssh as some user; you then can establish a + secure tunnel to the remote server. A secure tunnel listens on a + local port and forwards all traffic to a port on the remote machine. + Traffic sent to the remote port can arrive on its + localhost address, or different bind + address if desired; it does not appear as coming from your + local machine. This command creates a secure tunnel from the client + machine to the remote machine foo.com: ssh -L 63333:localhost:5432 joe@foo.com The first number in the argument, 63333, is the - port number of your end of the tunnel; it can be any unused port. - (IANA reserves ports 49152 through 65535 for private use.) The - second number, 5432, is the remote end of the tunnel: the port - number your server is using. The name or IP address between the - port numbers is the host with the database server you are going to - connect to, as seen from the host you are logging in to, which - is foo.com in this example. In order to connect - to the database server using this tunnel, you connect to port 63333 - on the local machine: + local port number of the tunnel; it can be any unused port. (IANA + reserves ports 49152 through 65535 for private use.) The name or IP + address after this is the remote bind address you are connecting to, + i.e., localhost, which is the default. The second + number, 5432, is the remote end of the tunnel, e.g., the port number + your database server is using. In order to connect to the database + server using this tunnel, you connect to port 63333 on the local + machine: psql -h localhost -p 63333 postgres - To the database server it will then look as though you are really + To the database server it will then look as though you are user joe on host foo.com - connecting to localhost in that context, and it + connecting to the localhost bind address, and it will use whatever authentication procedure was configured for - connections from this user and host. Note that the server will not + connections by that user to that bind address. Note that the server will not think the connection is SSL-encrypted, since in fact it is not encrypted between the SSH server and the PostgreSQL server. This should not pose any - extra security risk as long as they are on the same machine. + extra security risk because they are on the same machine. @@ -2587,12 +2592,12 @@ psql -h localhost -p 63333 postgres - You could also have set up the port forwarding as + You could also have set up port forwarding as ssh -L 63333:foo.com:5432 joe@foo.com but then the database server will see the connection as coming in - on its foo.com interface, which is not opened by + on its foo.com bind address, which is not opened by the default setting listen_addresses = 'localhost'. This is usually not what you want. --tThc/1wpZn/ma/RB--