About Heroku config on xplenty-ssh-tunnel application - heroku

We are trying to connect MSSQL(directly purchased from Heroku) in Xplenty through an SSH tunnel connection. I would like to ask what should be the SSH host name in heroku config?

Related

Access public PostgreSQL server (Amazon RDS) from personal computer through proxy

I'm new to Amazon Web Service (AWS).
I already created a PostgreSQL from AWS RDS:
Endpoint: database-1.XXX.rds.amazonaws.com
Port: 5432
Public accessibility: Yes
Availablity zone: ap-northeast-1c
After that, I will push my application that using the database to AWS (maybe deploy to EKS).
However, I want to try testing the database server from my local computer first.
I haven't tried testing from my laptop PC at home yet, but I think it will connect OK because my laptop PC is not using the HTTP proxy to connect to the network.
The problem is that I want to try testing from my company PC, which needs setup the HTTP proxy to connect to the internet. The PC spec:
Windows 10
Installed PostgreSQL 10
Firstly, I tried using psql command-line:
psql -h database-1.XXXX.rds.amazonaws.com -U postgre
> Unknown host
set http_proxy=http://user:password#my_company_proxy:3128
set https_proxy=http://user:password#my_company_proxy:3128
psql -h database-1.XXXX.rds.amazonaws.com -U postgre
> Unknown host
set http_proxy=http://my_second_company_proxy:3128
set https_proxy=http://my_second_company_proxy:3128
psql -h database-1.XXXX.rds.amazonaws.com -U postgre
> Unknown host
Then, I tried using the pgAdmin tool.
As from the internet post, it said that we can use "SSH Tunnel" for inputing proxy:
However, the error message will be shown:
So, anyone can help suggest if we can connect to the public PostgreSQL server through HTTP proxy?
I think problem is Postgres uses plain TCP/IP protocol and you are trying to use HTTP proxy. Also you're trying to create SSH tunnel against your HTTP proxy server which won't work.
So I'd suggest following solutions:
Use TCP proxy instead of HTTP proxy
Create an EC2 or any instance that has SSH access from your company network and has access to public internet. So that you can create SSH tunnel through that instance to achieve your goal.
NOTE: Make sure you PostgreSQL is accessible from public internet (although this is usually bad idea, but it's out of scope this question) sometimes security group configs prevent it to connect from public internet.
Just add all ports(5432,3128...) in the Security Group from your RDS and specify your IP. Don't forget "/32"
Let me add that "unknown host" is usually an indication that you're not resolving the DNS hostname. Also, your HTTP proxy should not interfere with connections to databases since they aren't on port 80 or 443. A couple of things you can try (assuming you're on windows) sub in your actual url:
nslookup database-1.XXXX.rds.amazonaws.com
telnet database-1.XXXX.rds.amazonaws.com 5432
You should also check the security group that is attached to your RDS and make sure you've opened up the ip address that you're originating from on port TCP/5432.
Lastly check that your VPC has DNS and Hostnames enabled. https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-updating

Unable to connect MongoDB Compass to AWS DocumentDB using SSH tunnel

I am new to mongoDB trying to setup tools for my new project. Most of my infrastructure run on AWS so i prefer to use AWS documentDB. I manage to connect to documentDB from EC2 both via mongo client or NodeJS aplication. but it would be good to mange documentDB from my Windows workstation using MongoDB Compass.
As we know, we can not direct connect any mongo client from outside AWS to DocumentDB Connecting to an Amazon DocumentDB Cluster from Outside an Amazon VPC
so we need SSH tunnel through EC2. I try many options but still fail... below are most likely 2 options:
Option 1: Connect using MongoDB Compass SSH tunnel
Error: unable to get local issuer certificate
both RDS-COMBINED-CA-BUNDLE.PEM and SSH Key already supplied so which one unable to get?
as red highlight on SSH port, I also tried to open another SSHD port on server and tried to connect using second port but still failed.
Option 2: Connect using Putty SSH tunnel
Error: Hostname/IP does not match certificate's altnames...
since MongoDB Compass need to connect to locathost to get into tunnel and i still can not find the way to supply --sslAllowInvalidHostnames options.
So, what i can do to get around this ?
MongoDB Compass: 1.25.0
I am done with Compass.
successful established "robo3t" connection to AWS DocumentDB using this guild.
https://docs.aws.amazon.com/documentdb/latest/developerguide/robo3t.html
As of Jan 2022 MongoDB Compass does not support sslInvalidHostNameAllowed=true in the connection builder form, this is the parameter you are missing in order to connect to AWS DocumentDB while ssh tunneling to a machine inside the same VPC of the database itself.
I used Studio 3T and it worked perfectly. You could create the connection string yourself or try other GUI.
Edit Jan 2023:
I just gave a try to compass again and it seems they now support sslInvalidHostNameAllowed flag through the UI, you could still change manually the connection string but then any UI interaction would overwrite it.
If you edit the connection string directly in MongoDB Compass you can set options that may not be accessible in the user interface.
Below is an example with tweaked parameters to connect without using TLS:
mongodb://xxxx:yyyy#localhost:27017/?authSource=admin&connectTimeoutMS=10000&readPreference=primary&authMechanism=SCRAM-SHA-1&serverSelectionTimeoutMS=5000&appname=MongoDB%20Compass&ssl=false
For Hostname, are you using DocumentDB endpoint? In one screenshot, I see you are using localhost.
I have managed to connect with option 1.
The workaround can be by establish connection using SSH Tunnel (port forward) and so that SSH tunnel opens a port on your local system that connects through to another port at the other end of the tunnel.
Using the below command establishes a tunnel on terminal and later you can use this channel/connection to connect MongoDB using MongoDB Compass.
For example:
ssh user#aws-ec2-ip-address -L 35356:127.0.0.1:27017 -N
where -L as the Local listening side
Port 35356 is listening on localhost (that is in this case your EC2) and port forwards through to port 27017 on remote server.
Note - Add identity file in .ssh/config
Ex - On Mac
Host XXXXXXX
HostName 52.xx.xx.xx
User ubuntu
IdentityFile ./path/prod.pem

Heroku Postgres connection from another ec2 instance

How can i connect to heroku postgres from another webapplication running on different cloud service.
I have a heroku postgres. I have another webapplication running on EC2. When my webapp on ec2 is trying to connect to heroku app, it fails.
I tried telnet from ec2 instance to heroku postgres on port 5432, it fails.
Can anyone please provide a pointer?
You can use heroku pg:credentials command to get the credentials for your database. For example:
$ heroku pg:credentials DATABASE_URL
Connection info string:
"dbname=abcdefghijklmn host=ec2-1-2-3-4.compute-1.amazonaws.com port=5432 user=abcdefghijklmn password=abcdefghijklmnopqrstuvwxyz sslmode=require"
Connection URL:
postgres://abcdefghijklmn:abcdefghijklmnopqrstuvwxyz#ec2-1-2-3-4.compute-1.amazonaws.com:5432/abcdefghijklmn
Then, you can use Connection URL or decomposed credentials in your other application. Pay attention to sslmode=require. Connections to Heroku Postgres require you to use SSL, which is an "advanced" option in some of the PostgreSQL clients (e.g. Navicat). For example:
$ psql postgres://abcdefghijklmn:abcdefghijklmnopqrstuvwxyz#ec2-1-2-3-4.compute-1.amazonaws.com:5432/abcdefghijklmn
More information here: https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress

Connecting to Heroku using port 443

I'm a university student and all ports except 80, 443 are blocked. I'm able to connect to github via
Host github.com
Hostname ssh.github.com
Port 443
git push heroku master gives me this error:
ssh: connect to host heroku.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
I've tried the solutions posted here on SO but I've still not got it working. Is there a way I can connect to heroku do deploy my websites?
Thanks a lot
Heroku ssh only works over port 22. There is, however, a plugin that lets you push via HTTP. It does not use git, though. Instead, you heroku push.
https://github.com/ddollar/heroku-push
If your SSH port been blocked and wish to push into heroku using alternate port then you may consider Tunneling.
For tunneling you are required to have additional PC or Server resides outside of blocked network and having access to Port 22.
For the scenario below we can use house PC to tunnel into heroku server. Since the university network only allow Port 80 and 443, we can set the House PC to receive connection via port 443 and tunnel it to port 22.
At House PC:
Configure SSH server in the house PC to run on port 443. Refer here to configure SSH Server on Multiple Ports
University PC:
Configure University PC to resolve git_tunnel alias to point to localhost on port 9001. Edit ~/.ssh/config and add following
# ~/.ssh/config
Host git_tunnel
Hostname 127.0.0.1
User git
Port 9001
Add a new remote alias as tunnel which will point to git#git_tunnel:{app name}.git
git remote add tunnel git#git_tunnel:{app name}.git
From the University PC establish tunnel to house PC which listening on port 443.
ssh -L 9001:heroku.com:22 -p 443 root#housepc.com
Deploy to heroku using alias tunnel created earlier
git push tunnel master

ssh to amazon EC2 over proxy

I have some problem connecting to my amazon EC2 server over ssh over proxy.
I have my username and password for http proxy port 8080.(dont have control over proxy)
Also I have my connection string which would work without proxy
ssh -i key.pem root#xx.compute.amazonaws.com
when I am trying to connect I am getting "No route to host" error
I tried to use putty, configured proxy + authentication file, But then I getting this error
"Unable to use this key file (OpenSSH SSH-2 private key)"
Also I dont know how putty inserts my proxy config, into ssh connection string, so I could try it in terminal
I was facing the same problem and this is what I used to connect, using corkscrew. My config file looks like this
Host AWS
Hostname <Public DNS>
Port 443
#Write the appropriate username depending on your AMI, eg : ubuntu, ec2-user
User ubuntu
IdentityFile </path to key file>
ProxyCommand /usr/bin/corkscrew 10.10.78.61 3128 %h %p
then I simply use this command to connect
ssh AWS
and it works flawlessly.
Note : You must edit your sshd_config file on the server to listen to ssh connections on port 443 (in addition to 22) and restart the ssh daemon.
Are you sure you can login as root? Try logging in as ec2-user instead.
Also, if you have assigned an elastic IP to your instance, the public DNS has probably changed. Log in to the aws console, and select your instance. Scroll down to look at the public DNS again and double check you are using the correct xx.compute.amazonaws.com addr.

Resources