Server unexpectedly closed network connection on AWS EC2 - mysql

It is a MySQL database server. When I login in AWS management console, it looks normal. But cannot connect to the server from any applications (PUTTY, MySQL clients, etc). Other than create a new instance, any ideas?

You cannot create new instance on aws. You can install phpmyadmin https://www.phpmyadmin.net/downloads/ and just upload it using sftp and extract then access on the browser http://ec2/phpmyadmin_directory_name.
If you are trying to access ssh then you have to create pem key link : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
then add the key to your putty. Thats it.

Related

How do I connect an AWS RDS instance and Datagrip?

I have created a AWS RDS database instance and I am trying to connect it to Datagrip. I chose Easy create, MySQL, Freetier and set the name as audiotranscribe. The profile of the instance is as follows:
In Datagrip I selected MySQL as the data source, used the password and username I set the instance up with, and set the hostname as the endpoint:
However, I'm getting the error:
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up. java.net.UnknownHostException:
Could anybody explain what I'm doing wrong? Thanks.
The instance is not publicly accessible, so you will not be able to connect to it from the Internet. You will need to either make it publicly accessible (not a good idea) or connect to it through a VPN.

Navicat doesn't recognize new entries in known_hosts file on Mac and cannot connect to remote server

UPDATE Feb 2022: this issue may have been fixed in more recent versions. See comments on the accepted solution.
Summary:
An existing connection to a remote database in Navicat was working using a domain name for the SSH > Host field. After building a new remote server and pointing the domain at the new IP address (and setting up the database and users, as well as adding your public RSA key to the new server), Navicat doesn't trust the key hash from the server. Replacing the entries in ~/.ssh/known_hosts doesn't help.
Steps to reproduce:
point the domain for a remote database at a new IP address
add your RSA public key to the authorized keys on the remote server
add the remote database and users on the remote server
in Terminal, ssh into the new remote server using the domain, and follow the prompts to add the new server to the known_hosts file
in Navicat (specifically Navicat Essentials for PostGreSQL, but this issue will apply to any app in the Navicat suite on Mac) edit an existing connection to the remote server
on the SSH tab in the "Edit Connection..." window, click 'Test Connection'
Expected:
Navicat uses the updated ~/.ssh/known_hosts file to authorize connection to the remote server
Actual:
Navicat fails to connect
Error:
The server key has changed. Either you are under attack or the administrator changed the key.
New server key hash:...
Question:
How to get Navicat to accept the new known_hosts data and authorize the connection?
Problem:
Navicat uses a different known_hosts file than the operating system does. So updating ~/.ssh/known_hosts doesn't affect the Navicat connection to the remote server.
Solution:
Optional workaround:
in Navicat, edit the database connection
on the SSH tab, change the Host field from a domain to the new IP address
Fix:
in Terminal, run sudo find ~ -name known_hosts
the results will include something like (using Navicat Essentials for PostgreSQL as an example):
/Users/<user>/Library/Containers/com.prect.NavicatEssentialsForPostgreSQL12/Data/.ssh/known_hosts
edit that file and remove the line starting with the domain for your remote server
return to Navicat and click Test Connection again. The connection should work.
If you see the error: Access denied for 'publickey'. Authentication that can continue: publickey,password (101203) or similar, check the Authentication Method selection and, if you're using 'Public Key' or 'Password and Public Key', click the 'Private Key' file navigator and re-select one of the private keys matching a public key that you've added to the remote server.

AWS connect to database

I created a database on AWS - RDS.And created a nodes app.
On MySql Workbench localhost I connected to database using endpoint and it was success and I got data on localhost/users
I deployed the nodejs app server to AWS but I did not get any data when I tried to call https://xalynj2ul4.execute-api.us-west-2.amazonaws.com/staging/users.
Try white-listing your node server in mysql host config file by entering your server ip in it

Connecting MySQL on EC2 to Tableau

I used a quick start guide to create a mysql database on EC2 that I can access and query using RStudio. However, I'd like to use Tableau Desktop to visualize the data as well. Tableau can connect to MySQL, but Im not sure how to make it work with EC2. I think I need to use port forwarding. I've Googled extensively and found a few examples but I'm completely new to this and don't know where to begin.
I'm using Terminal on Mac OSX. I'm able to login to SSH and to MySQL once in SSH.
Tableau needs a server, port, user, pass, and initial SQL statement. I'm assuming the initial SQL statement is just "use MyDatabase;"
I remember running into this issue awhile ago and found the solution again. I think the main thing to remember is that you have to use the localhost as the address in Tableau after you ssh into EC2 instead of the address of the actual EC2. You also have to setup your ssh to forward the port as you mentioned. Here is how you do that with PuTTY.
In the first screenshot you will see I added 127.0.0.1:3306 as the destination. This is the address of MySQL as setup on your server. I included 9990 as the source port. This is the port that PuTTY will be monitoring for any given calls. Once you have these defined click add and then save your session and connect with your server credentials through PuTTY. Go to Tableau.
In the second screenshot you will see that I used 127.0.0.1 for the server and 9990 for the port that I defined in PuTTY. You then add the credentials in Tableau that correspond to your MySQL user that is setup on EC2.

How do you setup SSL to connect to an RDS MySQL Instance

I am new to RDS Instances and Security, I am wondering how I can setup SSL to connect to my MySQL RDS Instance so i can do the following
connect to my RDS through SequelPro Application
connect via PHP (my framework is laravel)
I looked everywhere and AWS only gives me a rds-combined-ca-bundle.pem key and a rds-ca-2015-{regional-key} i don't even know what to do with these.
RDS Bundle and MySQL Specific Link
SSL requires a key file, a certificate file and a CA certificate file.
Any help would be great. Thank you
The documentation you link to directly specifies how to connect to an RDS instance via SSH:
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.SSLSupport
mysql -h myinstance.c9akciq32.rds-us-east-1.amazonaws.com \
--ssl-ca=[full path]rds-combined-ca-bundle.pem --ssl-verify-server-cert
So the questions now are:
How to get SequelPro to connect via SSH:
According to the SequelPro documentation, it only can connect via SSH using an SSH tunnel.
So you'll need to connect via SSH from your local computer to an EC2 instance in your VPC. Getting this setup has nothing to do with your RDS instance. Once that connection is established, you would use this tunnel to make a non-SSH connection to your RDS instance.
See: https://sequelpro.com/docs/get-started/get-connected/remote
Connect to RDS from your PHP app:
Similarly, it looks like PHP does not have built-in SSH support for MySQL connections.
There are many QA on Stack Overflow on this topic:
Connect to a MySQL server over SSH in PHP
Connect to a mysql database via SSH through PHP
Conclusion
In both accounts, it looks like SSH tunnels is the only way to go. So you either:
live with the tunnels,
use standard connection (non-encrypted), or
use other tools/mechanisms to connect that do support SSH.
You can not access the underlying server via SSH on the RDS product. If you absolutely have to have access you will need to install the database on an EC2 instance and forgo the benefits of using RDS
See https://forums.aws.amazon.com/message.jspa?messageID=153017