I have a Postgres database on a linux server. I have root access which in turn can give me access to the database. In Windows you get PGAdminIII, which I would love to use to connect to the Linux server. I heard that tunneling might be necessary. I am not sure if that is true, or what it is really. Can anyone shed some light on the easiest way to get access to the database?
Tunneling is not strictly necessary. As long as you have port 5432 not firewalled, you should be able to connect to your Linux PostgreSQL server without much trouble.
You can check this from your Windows box by using this command from cmd console:
telnet linuxbox 5432
If you get black screen (not an error), then everything looks good and port 5432 should be open. Note that on Windows 7 you may need to enable telnet client (it is disabled by default) using this command:
pkgmgr /iu:"TelnetClient"
If your server is not located in your local network, or if you are concerned about security like somebody using network sniffer to watch your traffic, you should configure SSL/TLS on your PostgreSQL server - it is not very difficult to do, and completely free when using self-signed certificate.
Note that by default Postgres on Linux does not listen on network interfaces, you may need to enable it by editing postgresql.conf.
Related
I'm trying to follow the digital ocean tutorial on configuring pgadmin4 in server mode, but damn it is long, and I have to first configure apache server, python and virtualenv (via other 2 tutorials).
I don't want to install so many dependencies in my server just to access postgres via pgamin 4.
How do you guys do it?
I'm running a go webserver via https listening on ports 443 and redirecting 80 to 443
Seeing your other answer I would like to offer a more secure alternative.
What's wrong with the current approach?
Your PostgreSQL instance is accessible from the internet. Generally you should try to limit access only where it is required. Especially if you are not using SSL to connect to PostgreSQL, an open port like this is a target for traffic interception and brute force attacks.
Alternative
Seeing that you are you using JetBrains IDE's you only need one other step to access your data - setting up a SSH tunnel.
This encrypts with SSH all your connections between development host and server without exposing PostgreSQL to the outside world.
In the connection settings for your database in the Jetbrains IDE select the SSH/SSL tab and "Use SSH tunnel". Input the information of your server and the SSH user + password/SSH key (use SSH keys for better security) into the relevant input fields.
Undo the settings changes you did to open the firewall and configure PostgreSQL to listen to all nodes.
Connections to your database are now possible over encrypted tunnels without exposing your database to any unwanted attacks.
So this is what I did to achieve connection from my laptop to my ubuntu VPS, via webstorm (I suppose any intellij works also should work with other IDE's)
0 login to your server
1. Locate postgresql.conf usually under /etc/postgresql/10/main
2. sudo nano postgresql.conf
3. Locate and change line at connections
listen_addresses = '*'
Then in same dir edit: sudo nano pg_hba.conf
#TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
Md5 means I connect with user and his password
5 Dont forget to allow ufw (firewall)
sudo ufw allow 5432/tcp
Open webstorm > Database (tab) > click + to add PostgtresSQL source (fill relevant info, user name, password, database name, host and port, etc...)
jdbc:postgresql://example.com:5432/my_database_name
Press on schemas and synchronize OR press:
Source > Settings > Schemas tab > [check] All Databases > refresh
I am running postgresql in WSL Ubuntu on windows. Everything is up to speed, my data is loaded and I wish to access the database through some graphical interface. I was thinking pgadmin4.
Is it possible to accomplish this through a windows install of pgadmin4? I installed pgadmin4 on windows and tried to connect the traditional way in the GUI through localhost but am not getting a connection. I figure there may be a special method here.
For everyone else stumbling across this: The best way to do this (that I know of) is to SSH into your local WSL and then configure the SSH in pgAdmin to that.
I have yet to figure out, how to use this remotely.
As long as postgres is running within your wsl2 instance (check with sudo service postgresql status) then within PgAdmin 4 (running in windows), all you need to do is click to "Register" a new server.
Then, while entering the Connection data, set host to localhost and port to 5432 (unless you specified unique port within your postgres instance when creating in wsl2.
See this answer for more detail
There is no special way needed, you should be able to get a connection. Just like your dev http ports are exposed to your browser on Windows, your db port should too.
I had to manually add localhost to pg admin though which is a bit weird.
Make sure your db service is up and running on Ubuntu, sometimes the db service is killed for no reason.
To see if your PostgresSQL service is up or not:
sudo service postgresql status
If it's not, start the service:
sudo service postgresql start
I am running a Postgresql server hosted on heroku as part of an app I am developing. I've been using PGAdmin as a frontend to set up my tables and also check to make sure the app is correctly writing data to the tables. When I am at home it connects fine and I can use it with no problems. It also works when I tether to my phone's WiFi hotspot. However when I am in university on the WiFi it does not connect. I get the following error:
"could not connect to server: Connection timed out (0x0000274C/10060) Is the server
running on host <MY HOSTNAME> and accepting TCP/IP connections on port 5432?"
I'm trying to troubleshoot this. I tried the obvious things like checking my hostname and port are correct (they are, because it works from home!) and checking that Pgadmin has permissions in windows firewall (it does). Not sure what to try next.
Is it likely to be that the port is blocked? I used an online port checker which reported that the port (5432) was closed, however it also says this when using my phone's wifi hotspot (which normally works, as I said). Is there another port I can use with Postgresql?
OK, it turns out the port 5432 was actually closed on my university's WiFi. I was able to request that it be opened, and everything is now working.
I have been using rockmongo as my client for mongodb on localhost for testing.
For prodction i DONT want a client online as this might reduce security.
Is there a client which will allow me to connect SSH? kind of like MySql Workbench?
or
Can rockmongo stay on my local computer and i connect to EC2 instance which has mongodb for production viewing?
or
Is there a better alternative to all of this?
My setup is a standard LAMP stack. willing to make any changes necessary.
MongoHub has the option to connect over ssh, but the app kind of sucks. It crashes a lot.
A more generic approach would be to just create your own ssh tunnel to your production server, and then connect over that through whatever client you want. The client won't care as long as it can make the connection.
On OSX/Linux, creating an ssh tunnel might look like this:
ssh -L 8080:127.0.0.1:27017 -f -C -q -N username#domain.com
This would open a local port 8080 which will forward the traffic to the localhost interface at the mongodb default port 27017 on the remote side. You would point your client at 127.0.0.1:8080 as if mongodb were running there locally.
Check some of these out - http://www.mongodb.org/display/DOCS/Admin+UIs
One workaround would be to set that file in a separate folder and make a .htaccess file that restricts access to only your ip address. Any requests not from your ip address would get denied access...
I am wondering if it is possible while using MAMP to have the database online?
I am developing a couple sites locally between work and home, and initially thought I could get mamp to store or point to my external drive. No bueno.
SO am thinking I can still run mamp at work or at home pointing to my external drive but the DB that it would connect to would be online?
Depending on your system you could set up an SSH tunnel to another computer running the database. SSH tunneling allows you to direct a port on your computer (For example port 8889 which MAMP uses by default for the MySQL port) to a port on another computer. If set up correctly, you tell MAMP that you are using local port 8889, but ssh will then direct all traffic to the remote computer's mySQL port which is where you could run your database. This link has a good tutorial on how to do this provided that you have ssh installed.