SSH Connection Using Pgadmin4 on Ubuntu 16.04

Pgadmin4 has a GUI for connecting to a remote DB. Seems pretty straight forward. And then you get this error:

module ‘paramiko’ has no attribute ‘Ed25519Key’

After some googling you find this Stack Overflow post. Looks like you need to install paramiko 2.4. If you follow the instructions in SO, you end up with a failed install due to missing dependencies. Turns out there is no pre-built distribution of paramiko 2.4 for Ubuntu 16.04.

If you move on the the SO answer that suggests editing /usr/lib/python3/dist-packages/ I tried that. It was easy. Only two lines needed to be removed. However after that, I kept getting errors like ‘Could not establish session to SSH gateway’ and ‘Could not connect to gateway’.

Eventually I solved the problem by creating an ssh tunnel from the Ubuntu command line and then connecting to the tunnel in pgadmin.




Vagrant, PostgreSQL and pgAdmin

Here’s how to use pgAdmin to inspect a database on a Vagrant virtual machine. Vagrant already has SSH setup so the easiest and most secure way to connect to that database is using pgAdmin’s SSH Tunnel feature. To do this, click the connection icon (a plug) and you will see something like this:

Screenshot from 2015-01-20 17:42:48

For Name you can enter anything. Note: Host is localhost, not the vagrant IP address . Username is the database username. Password is the database password. DO NOT CLICK OK yet. Instead, click the SSH Tunnel tab. You will see something like this:


Tunnel host is the IP address of the Vagrant VM. Username is the Linux username used when you SSH in to the virtual machine. The identity file is the SSH private key for this virtual machine. When you run “vagrant up”, it creates a .vagrant folder. The private key is in there in a folder like:


Now click OK and you should be connected.


I just started getting this error:

Error connecting to the server: server closed the connection unexpectedly
 This probably means the server terminated abnormally
 before or while processing the request.

Turns out the error was in the first GUI (above) for setting up the connection. For Host, I put the vagrant IP address. However, since I was using SSH Tunneling, the correct Host is localhost. Ugh…

Filters in pgAdmin

I use PostgreSQL in most of my Django projects. PostgreSQL has a tool called pgAdmin that is invaluable for debugging. pgAdmin allows the user to manually enter filters. The problem is the filter does not naturally handle column names that are capitalized, while Django often creates column names that are capitalized. What to do?

The solution is to put the column name in double quotes:

Job='xyz'    - is Not valid
"Job"='xyz'   - is valid