I add a server and there are Error like this
I use pgadmin4
How I can Fix this?
Firstly, check if the server is listening.
Use the following command on your server:
netstat -nlt|grep :5432
If it's ok, SSH (or whatever method you use to access the server) to your server and view the file:
/etc/postgresql/9.1/main/postgresql.conf
Find the line start with:
listen_addresses=
If the value after "=" is 'localhost', it means that you cannot connect from outside. To be able to do so, change it to:
listen_addresses='*'
Now you will be able to connect from anywhere, outside from the server itself. And, don't forget to restart you DBMS and check if it works.
Ah. One more thing, you may also need to give your user access rights to your database as well.
Open the file:
/etc/postgresql/9.1/main/pg_hba.conf
And add:
host all all * md5
You also need to restart you DBMS to fire up changes.
P/s: You should enable SSL.
Related
I am using the Remote-SSH extension in Visual Studio Code to connect to a remote machine. This remote machine is protected by Duo's two-factor authentication. When I SSH in a terminal (outside of VS Code), I'm able to log-in perfectly - the terminal prompts me through the 2FA process. However, inside VS Code when I'm using the extension, I am not able to log-in. After typing in my SSH hostname and ID, the VS Code interface prompts me for my password over and over again, and does not proceed beyond that point.
Has anyone encountered this issue before? I'd love to know if there is an existing solution. Unfortunately, 2FA is managed by my company and I can't turn it off.
I run into the same problem and fixed it by using SSH ControlMaster for Single Singe-On.
If you connect to the relevant machine using <user_name>#<host_name> you can simply add the following to your ~/.ssh/config:
Host <nickname>
User <user_name>
HostName <host_name>
ControlMaster auto
ControlPath ~/.ssh/%r#%h:%p
If you now open up a new session in your terminal running ssh <nickname> you will be asked for the password and the 2FA key. But all other subsequent ssh sessions (including svn, rsync, etc. that run over ssh) will piggyback off the initial connection without the need for re-authentication.
You can now in VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, ⇧⌘P) and simply enter: <nickname> and ControlMaster will automatically connect you using the already standing connection.
In my case, the nickname that I choose is "ody". After connecting VSC's Remote Development extension shows the following in the bottom left corner and lets me browse the files on the remote machine.
From the FASCR:
Note that all subsequent connections are dependent on the initial connection — if you exit or kill the initial connection all other ones die, too. This can obviously be annoying if it happens accidentally. It’s easily avoided by setting up a master connection in the background:
ssh -CX -o ServerAliveInterval=30 -fN <nickname>
The -fN make it go into the background and sit idle, after authenticating. (C for compression,Y for X forwarding, and o ServerAliveInterval=30 to prevent dropped connections have nothing to do with the ControlMaster but are almost always helpful.)
Note that all port forwarding, including X display forwarding, must be setup by the initial connection and cannot be changed.
Got to settings in VS Code and enable this setting, remote.SSH.showLoginTerminal. This pulls up the terminal so that sign in via 2FA that way.
You can use ~/.ssh/config file to configure your hostnames and keys. But I don't know if there is a way to save passwords for convenience.
I'm trying to figure out how I can connect to my DB via SSH using the IntelliJ "Database" feature. We are using OpenShift and there is one pod running, which is only our connection to our DB.
Example:
oc rsh pod_name
After that comes the psql connection string to login into our DB.
Can I somehow point to my script, so I can connect or is there a better way? The issue with this is, the pod name is dynamically changed now and then. That's why I want to point to my script which solves this issue by fuzzy searching the pod name.
here is doc on how to connect using SSH. How does your script work? can you point it to change pod name in OpenSSH config for example and do not establish SSH connection? Then you just use this config in Intellij with alias to create ssh tunnel and use it with database connection.
or there is another way: in data source properties on 'Options' tab you can use 'Before connection' configuration where you can add your script, which will create ssh tunnel using some static local port and set in database connection 'localhost:port'.
I'm exploring the new set extensions called VSCode Remote Pack and I want to connect to a Vagrant container using the Remote Container extension. Using a Windows 10 OS, how could I do that?
I tried the extension but it requests me to have Docker installed, what I suppose from that is that it only works for Docker containers. But I wonder if somebody have already managed to connect to a Vagrant box.
This are the docs from the extension: https://code.visualstudio.com/docs/remote/containers
VS Code Remote containers currently only support Docker (its implementation executes docker commands). Please open a feature request if you would like to see other tools supported.
As an alternative, you could try using Remote SSH to connect to vagrant containers. That should work but will require some extra container setup
Sorry for updating this so late.
The solution was pretty simple, as #MnZrk commented, what it needs to be done for setting up the connection is the following:
Run vagrant ssh-config > some-file.txt. This will generate a file with the configuration to run using SSH. Here an example of that file:
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/User/project/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
ForwardX11 yes
Notice that the host name is default, you could rename it to whatever you want so you could identify it more easily.
Copy the content of some-file.txt inside your SSH configuration file. This file could be edit directly from vscode by pressing F1 and writing Remote-SSH: Open Configuration File..., then you select the file you use for ssh configuration. After that file opens, just copy the content of some-file.txt there.
Finally, just press again F1 and type Remote-SSH: Connect to Host..., choose the connection with the host name default or the want you wrote in the first step, and that's all.
I am currently deploying to Digital Ocean using Meteor Up. If I don't specify a MONGO_URL in the mup.json, can I get the value from the command line while the website is running, i.e. I don't want to shutdown the site?
If I go to the app directory and run meteor mongo --url, I get the following error:
mongo: Meteor isn't running a local MongoDB server.
This command only works while Meteor is running your application
locally. Start your application first. (This error will also occur if
you asked Meteor to use a different MongoDB server with $MONGO_URL when
you ran your application.)
If you're trying to connect to the database of an app you deployed
with 'meteor deploy', specify your site's name with this command.
Even if I run the app from the app directory, it will only give the localhost MONGO_URL. I need the MONGO_URL for the deployed app.
I have also taken a look at a similar question as suggested by some of the answers. I disagree that it is "impossible" to get the MONGO_URL without some other program running on the server. It's not as if we are defying the laws of physics here, folks. Fundamentally, there should be a way to access it. Just because no one has yet figured it out doesn't mean it is impossible.
meteor mongo --url should return the URL.
Try opening another shell in the app directory and running that command.
Meteor Up packages your app in production mode with meteor build so that it runs via node rather than the meteor command line interface. Among other things, this means meteor foo won't work on the remote server (at least not by default). So what you're really looking for is a way to access mongo itself remotely.
I recently set up mongo on an AWS EC2 instance and listed some lessons learned here: https://stackoverflow.com/a/28846703/2669596. Some details of how you do it are going to be different on Digital Ocean, but these are the main things you have to take care of once mongo itself is installed:
Public IP/DNS Address: This is probably fine already since you can deploy to the server.
Port Security Rules: You need to make sure port 27017 is open for TCP access, at least from your IP address. MongoDB also has an http interface you can set up; if you want to use that you'll need to open 28017 as well.
/etc/mongod.conf (file location may differ depending on Linux flavor):
Uncomment port=27017 to make sure you have the default port (I don't think this is actually necessary, but it made me feel better and it's good to know where to change the default port...).
Comment out bind_ip=127.0.0.1 in order to listen to external interfaces (e.g. remote connections).
Uncomment httpinterface=true if you want to use the http interface.
You may have to restart the mongod host via sudo service mongod restart. That's a problem if you can't have downtime, but I don't know of a way around that if you change the config file.
Create User: You need to create an admin and/or user to access the database remotely.
Once you've done all of that, you should be able to access the database from your local machine (assuming you have the mongo client installed locally) by running
mongo server.url.com:27017/mup-app-name -u username -p
where server.url.com is the URL or IP address of your remote server, mup-app-name is the appName parameter from your mup.json file, username is the user you created to access the database, and you'll be prompted for that user's password after you run the command (or you could put it after -p on the same line, depending on the password).
There may also be a way to do this by setting up nginx to reverse-proxy 127.0.0.1:27017 on your remote server, but I've never done it and that's just me speculating.
I can easily connect to a remote MySQL server using the DBI module in my Perl scripts. However, when I try to use the same connection settings/properties from within a CGI script, the connection fails.
There are no helpful errors/warnings being logged either in the apache error log, or the browser, in spite of using
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
Strangely, the exact same script works fine when executed from the terminal. I also tried connecting the CGI script to the MySQL server on localhost, but without any success.
On the other hand, phpMyAdmin works great on the machine.
I'm using CentOS Release 5.8. I'm suspecting it is a system/priveleges issue with the apache user or anywhere else on the OS, but have hit a dead end.
Any pointers would be much appreciated!
Thanks a lot.
Edit: I'm using the following connection string
$dbh = DBI->connect($ds, $uname, $pwd,{RaiseError => 1 }) or die "$DBI::errstr Could not connect: $!<br>";
Fixed it. In case anyone not too familiar with Linux administration faces similar issue, here's what had happened. The security system 'selinux' on my CentOS machine was prohibiting the httpd to establish network connection to the remote MySQL server. It had to be explicitly enabled with the following command
setsebool -P httpd_can_network_connect=1
One can read more about selinux over here:
http://wiki.centos.org/HowTos/SELinux
Check what users you have set up in MySQL. If you're trying to connect across a network connection, you could have a problem with the host association for the user.
Try:
select host,user from mysql.user