Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

SSH connect to PostgreSQL service instance

Valued Contributor
Valued Contributor

Hi All,

 

I would like to share the guideline how to make SSH connection to PostgreSQL service instance on Cloud, and you can do a rapid development with PgAdmin 4 from local.

 

  • Get application environment info:  cf env appName
  • Take note

         Host, name, username, pass

         2018-06-29_16-33-31.png

 

  • Connect by ssh command:

          cf ssh appName -L 5433:host:5432

 

          -L: 5433 for local port server setup

      2018-06-29_16-53-12.png

 

  • Create local server to connect and manage the DB2018-06-29_16-45-46.png
  • Connected and query as local database
  • Disconnect SSH by exit command

 

 

Hope this helpful for your development

 

Thanks

Hoang Doan

 

 

13 REPLIES 13

Re: SSH connect to PostgreSQL service instance

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi

Thanks for the info. This is exactly what I did yesterday and got it sorted. Anyways kudos for sure for the reply. Smiley Happy

Re: SSH connect to PostgreSQL service instance

Valued Contributor
Valued Contributor
Thank you Sajan

Re: SSH connect to PostgreSQL service instance

Experimenter
Experimenter

Hi,

We have tried the following command:

cf ssh appName -L 5433:host:5432

However facing some issues here. 

Error opening SSH connection: dial tcp <some_address>: connectex: A connection attempt failed because the connected party did not properly respond after a period
of time, or established connection failed because connected host has failed to respond.

Could you please let me know what could be the cause of this ?


The following image has the Error displayed for reference.

Thanks


Re: SSH connect to PostgreSQL service instance

Valued Contributor
Valued Contributor

Hi @MansiHundlani

 

Make sure your space and app are allowed ssh connection, try this one

cf allow-space-ssh SPACE-NAME
$ cf enable-ssh MY-AWESOME-APP

https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-apps.html#enable-disable-ssh

 

Thanks

Hoang Doan

Re: SSH connect to PostgreSQL service instance

Experimenter
Experimenter

 Hi,

 

Thanks for information.

 

I have some issue :

 

when i am logged through SSH tunnel to postgresql with my user i dont have previledge for delete schema,insert

data,create roles and view data in pgadmin4.

 

Priviledge shows for my user :

 

1)can login.
2)can inherit rights from the paarent roles.

 

So is there any option to resolve this. 

 

Thanks in advance Smiley Happy

Re: SSH connect to PostgreSQL service instance

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi @HoangDQ,

 

I tried your port forwarding/tunneling  solution. This work well when i am not in siemens network but it not work when i am in siemens network(due to siemens proxy). Could you please help me out ? 

 

I am trying to connect mongodb service instance on mindpshere.

Re: SSH connect to PostgreSQL service instance

Creator
Creator

Hello @HoangDQ

 

I am also getting ssh connection issue, for my tenant space and application ssh already enabled, could you hepl me out.

 

Error opening SSH connection: dial tcp <some_address>: connectex: A connection attempt failed because the connected party did not properly respond after a period
of time, or established connection failed because connected host has failed to respond.

 

Thanks in advance Smiley Happy

 

Regards,

Uppala Ravi

 

 

 

 

 

Re: SSH connect to PostgreSQL service instance

Legend
Legend

Just FYI, after the MindSphere Developer Days in Berlin last week, we have released an OSS demo project. Part of it is a script and documentation on how to perform such operations:

 

https://gitlab.com/mindsphere/devops-demo/blob/master/tools/README.md

https://gitlab.com/mindsphere/devops-demo/

 

@bufferoverflow

Re: SSH connect to PostgreSQL service instance

Siemens Creator Siemens Creator
Siemens Creator

Hi HoangDQ,

     Thanks for your info, I also desperately need a DB tool.

     Here, I have a question, you had bind the DB instance with an app, and through 'cf env app' get the instance info. If my db instance don't bind any app, how to use the tool bind mindsphere db instance?