Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Regardless of whether Postgres allows this functionality, you can enable a secure connection to a remote database by using SSH tunneling. Here's the gratuitous Stack Overflow paste-in from the Web docs:</p> <blockquote> <p>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:</p> <p>ssh -L 3333:foo.com:5432 joe@foo.com The first number in the -L argument, 3333, is the port number of your end of the tunnel; it can be chosen freely. 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. In order to connect to the database server using this tunnel, you connect to port 3333 on the local machine:</p> <p>psql -h localhost -p 3333 postgres To the database server it will then look as though you are really user joe@foo.com and it will use whatever authentication procedure was configured for connections from this user and host. 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.</p> </blockquote> <p>In case you want more, you can find it online by searching for "SSL tunnel" or "postgres SSL tunnel". Here's the Postgres site where I got the above:</p> <p><a href="http://www.postgresql.org/docs/current/static/ssh-tunnels.html" rel="noreferrer">http://www.postgresql.org/docs/current/static/ssh-tunnels.html</a></p> <p>To summarize for Rails, you would then do the following:</p> <p>1) In a terminal window, run the first ssh command above to establish the tunnel.</p> <p>2) Set your database props like so:</p> <pre><code>development: adapter: postgresql database: journalapp_development username: xxx password: yyy host: localhost port: 3333 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload