Can't remotely connect to MongoDB through an SSH channel - mongodb

I am having an issue connecting to a mongoDB through SSH. I commented out the bind_ip option (and then added the authorization option). But to no avail. I even allowed the port through my firewalls. I get this error
"Cannot establish SSH Tunnel (IP:22).
Error: Failed to create a SSH channel"
It is worth mentioning I am using Robo 3T, and the first step, connecting to the server passes.

You can try this:
Select whether Compass should connect to a MongoDB cluster via an SSH tunnel, which automatically starts when you connect to MongoDB, and stops when you disconnect. If selected, choose either a password or an identity file to provide authentication.
Link: https://docs.mongodb.com/compass/master/connect/

Related

How to configure and connect to a remote MongoDB server on a hosting provider server?

I've been trying to establish a connection to my MongoDB on my Cloud VPS hosting server.
I'm hosting my website on a Cloud VPS running Ubuntu 16.04 (my hosting provider is InMotion hosting if anyone knows them).
I've installed MongoDB on the server.
I've edited the /etc/mongo.conf file to bindIp: 0.0.0.0
Created an admin user db.createUser({user: "XXXXX",pwd: "XXXXX",roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"],mechanisms:[ "SCRAM-SHA-1" ]})
Restarted the service and checked the status that it is Active
Now, I'm trying to connect using RoboMongo, putting the server IP, user, and password and it doesn't connect.
To be able to connect via SSH I had to generate a public SSH key and then load the private key to PuTTY, so I even tried to connect RoboMongo with SSH. I've attached screenshots of the settings I've tried in RoboMongo.
When trying to connect with SSH I get this error:
Failed to create SSH tunnel to XXX.XXX.XX.XXX:22.
Error:
Authentication by key (PATH/id_rsa.ppk) failed (Error -16)
When trying without SSH I get this:
Cannot connect to the MongoDB at XXX.XXX.XX.XXX:27017.
Error:
Network is unreachable.

How to connect to MongoDB Atlas using Robo 3T?

I'm trying to connect to MongoDB Atlas using Robo 3T.
I must be doing something wrong, cause when i'm trying to connect I get the following error message:
Failed to connect to cluster via SSL tunnel.
in details: Error: ssl connection failure: Authentication failed.
What iv'e tried so far:
Selected a "Direct connection" type.
I used my primary cluster as address (including the port number)
for Authentication I used "admin" Database, and put my username (my email) and the password of MongoDB Atlas.
I also white listed my IP address, and even set it as "allow access from anywhere", though it's not secure.
I checked "Use self-signed certificate"
Nothing I do seems to work.
Any idea what am I doing wrong?
thanks
At Atlas connections are SSL encrypted.
Go to SSL Tab in the connection settings window
Select Use SSL Protocol option
Now try connecting.
Exclude the port number in your cluster URI. :PORT. Exclude the port then use ssl and self certificate.

Use Robo 3T to connect to remote MongoDB

I'm trying to use Robomongo (or Robo 3T) under Mac to control my mongodb in the remote Ubuntu & Nginx server.
Normally, I need to ssh xxx.xx.xx.xx in a terminal with a username and a password to connect to the server. in /etc/nginx/sites-enabled/myweb.io, there is listen 443 ssl.
In Robo 3T, I tried to set up the connection with Use SSH tunnel. I tried the port number 443 or 80. But it gave me an error: Error: Resource temporarily unavailable. Error when starting up SSH session: -13. (Error #35)
Does anyone know how to fix this?
The correct setting is
1) under SSH, check User SSH tunnel, use port 22
2) and under Connection, write 127.0.0.1:27017
I've done few configurations on my Ubuntu 18 Vagrant box in order to successfully connect MongoDB remotely using Robo 3T GUI. I've explained in the following steps.
On Ubuntu server, to open mongo shell run:
$ mongo
Inside mongo shell, type following command to create new a admin user.
> use admin;
> db.createUser({user:"admin", pwd:"password", roles:[{ role: "root", db: "admin" }]});
By default mongodb is configured to allow connections only from localhost(IP 127.0.0.1). We need to allow remote connections from any ip address. The following change should only be done in your development server. Open up etc/mongod.conf file and do the following change.
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 #default value is 127.0.0.1
Also in the same mongod.conf file uncomment security option and add authorization option as shown below.
security:
authorization: enabled
Save and exit the mongod.conf file and restart mongodb server.
$ sudo servcie mongod restart
Download and install Robo 3T GUI tool.
On Robo 3T GUI, in the connection settings, you need to do few changes as shown on
below screen shots.
Enter mongodb admin database username and password which you have created earlier.
Here, I have entered my Ubuntu 18 Vagrant box ssh credentials.
Save the changes and press connect icon to see if the connection is working fine.
Connect to remote MongoDB using Roto3t
Firstly, we should check the standard URI connection scheme
for mongodb
mongodb://[username:password#]host1[:port1][,...hostN[:portN]]][/[database][?options]]
We make a SSH Connection to the remote MongoDB on Cloudfoundry
in my case
cf ssh -L port_forwarding:HOST_NAME:Port NAME_OF_APP
(1) In the Connection tab in Robo3T we choose
Type: direct connection
Name: choose_any_connection_name
Address: localhost and port is 'port_forwarding' we choose in the SSH connection we made.
(2) in the Authentication tab, we should add database, username, password, and Auth Machanism: SCRAM-SHA-1
(3) in the SSH Tab we will uncheck use SSH tunnel as we made it manually.
Now, if you click test the connection should be successfully done.
Note: If we use Studio 3T it will parse the URI and fill all these fields for us.

Not able to connect MongoDB Compass

I am not able to connect my server in MongoDB Compass. I am trying to connect by identity file. I am providing hostname username and file.
I got:
'Error creating SSH Tunnel: Timed out while waiting for forwardOut'
What does it mean?
Hi, krl! I was getting the exact same error from MongoDB Compass Community 1.11.1 while trying to connect through an SSH tunnel, with a ppk file protected by a passphrase.
Are you putting your remote server IP or domain name in the first field (hostname)? That was my mistake.
What solved it for me was setting the Hostname field (the first one on top) to localhost instead of remote server IP or domain name. Put your domain/IP only on the field SSH Hostname.
I hope it helps.

PGAdmin III cannot connect AWS RDS

I am trying to connect AWS RDS PostgreSql from PgAdmin 3. I followed the below link
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
In Security Group, I also added PostgreSQL and All traffic as below
The "publicly accessible" flag was enabled (updated after Mark B's comment)
I got the error from PGAdmin3
Very appreciate for any suggestion
******UPDATE*******
I can connect pgAdminIII to AWS RDS successfully using home wifi, but cannot connect using office wifi.
My concern is:
Was the port 5432 blocked by office wifi?
How can I configure/update the port without impacting to current API?
Note: My current API is working well (CRUD)
Can you can test your connection to a DB instance using common Linux or Windows tools first?
From a Linux or Unix terminal, you can test the connection by typing the following (replace with the endpoint and with the port of your DB instance):
$nc -zv DB-instance-endpoint port
For example, the following shows a sample command and the return value:
$nc -zv postgresql1.c6c8mn7tsdgv0.us-west-2.rds.amazonaws.com 8299
Connection to postgresql1.c6c8mn7tsdgv0.us-west-2.rds.amazonaws.com
8299 port [tcp/vvr-data] succeeded!
Windows users can use Telnet to test the connection to a DB instance. Note that Telnet actions are not supported other than for testing the connection. If a connection is successful, the action returns no message. If a connection is not successful, you receive an error message such as the following:
C:>telnet sg-postgresql1.c6c8mntzhgv0.us-west-2.rds.amazonaws.com
8299
Connecting To sg-postgresql1.c6c8mntzhgv0.us-west-2.rds.amazonaws.com...Could not
open connection to the host, on port 819: Connect failed
If Telnet actions return success, then you are good to go.
If you are trying to access it from a network which is not listed for that port. you need to add inbound rules for those network IPs from AMAZON RDS system
You will also need to set Public accessibility true under Connect & security tab in RDS console.
Read this post.In your security group go to unbound rules and add my ip.
and make sure your database is public.
https://serverfault.com/questions/656079/unable-to-connect-to-public-postgresql-rds-instance