First of all you're not SSHing into a Database, SSH is only for EC2 instances. The logical steps would be:
- SSH from local computer to EC2 instance (optional depending on settings below)
- Connect to the database using something like
mysql -H (hostname) -u admin -p
it will prompt for password.
If you want to connected to the DB directly, make sure you whitelist your IP on the security group for the DB. The security group by default will not allow you to connect to it directly, or anywhere by default.
If you want to connect to the DB from your bastion host, again, you'll need to whitelist the IP of the bastion host.
Security groups are basic ALLOW from IP on PORT. So for MySQL the port will be 3306.
In AWS, there's a ton of variables why this may be failing.
- Are these resources in the same region?
- Are these resources in the same subnet? Is the subnet private or public?
During the configuration of RDS, at least in the past, you could not set the security group at all during the configuration. You always had to remember to go back and click Modify, then go in and give it a security group.
The best practice here around security groups, is to
- Create one for your bastion host instance, only allowing 22 to your home IP.
- Create one for your RDS instance, allowing 3306 from the security group ID of your bastion host. That way you don't need to worry about your bastion host IP changing, any instance that has the bastion host security group will be able to access 3306 on this RDS.
- Assign the security groups to the correct resources.
If you're still having problems, I can get much deeper on this.