{"id":328,"date":"2015-10-19T11:05:00","date_gmt":"2015-10-19T18:05:00","guid":{"rendered":"http:\/\/shanelabs.com\/blog\/?p=328"},"modified":"2023-01-04T15:27:46","modified_gmt":"2023-01-04T23:27:46","slug":"using-heidisql-to-connect-to-postgresql-through-ssh-tunnel","status":"publish","type":"post","link":"https:\/\/shanelabs.com\/blog\/2015\/10\/19\/using-heidisql-to-connect-to-postgresql-through-ssh-tunnel\/","title":{"rendered":"Using HeidiSQL to connect to PostgreSQL through SSH tunnel"},"content":{"rendered":"<p>Was trying to connect to a PostgreSQL database running through VirtualBox locally, but is only exposed though SSH. In order to do that, I have to connect through an SSH tunnel. I found the following article here&nbsp;http:\/\/www.heidisql.com\/forum.php?t=15472 that says:<\/p>\n<blockquote><p>SSH tunnel is built into HeidiSQL for MySQL only. For using a tunnel to a PostgreSQL server, you will need to start a plink.exe command line seperately, and then let HeidiSQL connect to 127.0.0.1 on the port you specified in the command line.<\/p><\/blockquote>\n<p>But I had no idea how to do that!<\/p>\n<p>Did some research, and here&#8217;s what I ended up running that worked for me:<\/p>\n<p>Make sure you have Putty installed (which included plink.exe). Open up a windows command prompt and navigate to the folder you have the Putty executables:<\/p>\n<blockquote>\n<pre>cd&nbsp;\"C:\\Program Files (x86)\\PuTTY\"<\/pre>\n<\/blockquote>\n<p>From there, run the following:<\/p>\n<blockquote>\n<pre>plink -L 5432:localhost:5432 \"my local ssh profile\"\n<\/pre>\n<\/blockquote>\n<p>where &#8220;my local ssh profile&#8221; is the name of the session config you have saved in PUTTY.<\/p>\n<p>What this does it route all requests from localhost port 5432 to the connection it created through PUTTY and forwards them to the same port (hence the second 5432)<\/p>\n<p>Now you just need to change the config for HeidiSQL to connect to &#8216;localhost&#8217;, port 5432. Then provide the user and password for the postgres database user you want to connect with.<\/p>\n<p>Hope that helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Was trying to connect to a PostgreSQL database running through VirtualBox locally, but is only exposed though SSH. In order to do that, I have to connect through an SSH tunnel. I found the following article here&nbsp;http:\/\/www.heidisql.com\/forum.php?t=15472 that says: SSH tunnel is built into HeidiSQL for MySQL only. For using a tunnel to a PostgreSQL [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-328","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=328"}],"version-history":[{"count":2,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/328\/revisions"}],"predecessor-version":[{"id":356,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/328\/revisions\/356"}],"wp:attachment":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}