dbcli / pgcli

Postgres CLI with autocompletion and syntax highlighting
http://pgcli.com
BSD 3-Clause "New" or "Revised" License
12.01k stars 551 forks source link

SSH tunneling with a SSH key #1330

Open warcayac opened 2 years ago

warcayac commented 2 years ago

I've installed these packages:

$ pip install --upgrade pgcli
$ pip install sshtunnel

I'm trying to run:

$ pgcli postgresql://someone:secret1@localhost:4567/mydb --ssh-tunnel anyone:secret2@111.222.333.444:789

I get this output:

Could not establish session to SSH gateway

Indeed I use a custom SSH key: ~/.ssh/chesu_rsa

so I tried with:

$ pgcli postgresql://someone:secret1@localhost:4567/mydb --ssh-tunnel anyone:secret2@111.222.333.444:789 -i ~/.ssh/cype_rsa

or

$ pgcli postgresql://someone:secret1@localhost:4567/mydb --ssh-tunnel anyone:secret2@111.222.333.444:789 -K ~/.ssh/cype_rsa

I get these error messages respectively:

Error: No such option: -i
Error: No such option: -K

How do I resolve this problem?

PS: I'm using latest version of pgcli and sshtunnel.

favadi commented 1 year ago

Make sure you don't use ProxyJump in ~/.ssh/config for the tunnel host. I have the same error and replacing ProxyJump with ProxyCommand ssh -W %h:%p fixed it.