Safely Through the Gates: SSH Tunneling to connect multiple
remote AWS private resources.
Hola!!! ππ»ββοΈ
In todayβs cloud-driven world, securely accessing resources hosted on AWS is paramount. In this post, weβll explore how to securely access multiple private RDS instances, EKS, EC2, etc. on AWS using SSH tunneling.
πSetting Up SSH Config
To streamline the process, we can leverage SSH config files. Below is an example SSH config file tailored for accessing multiple private instances through a bastion host:
πππ ~/.πππ/ππππππ
π·πππ πππ_ππππππ_ππππππππ
ππππ ππππππ
π·πππππππ <ππππππππ ππ ππ πππππππ ππππ>
πΈπππππππ’π΅πππ ~/.πππ/πππππππ-ππππ.πππ
ππππππππππ ππ
πΏπππ‘π’π²ππππππ ππ -π βππ π πππ πππππ-πππππππ β πππππππ ππ π-πππππππ β ππππππ ππ-ππππ-π· β ππππππ %π β ππππππππ-ππππ π°ππ-ππππππππ·πππππππ β ππππππππππ βπππππ½πππππ=%πββ
π»πππππ΅πππ πππ π»πΊπΉπ· πππ-ππ-ππππππππ:π»πΊπΉπΈ
π»πππππ΅πππ πππ π»πΊπΉπΈ ππ-ππ-ππππππππ:π»πΊπΉπΈ
π»πππππ΅πππ πππ π»πΊπΉπΉ πππ-ππππππππ:πΊπΊπΉ
πExplanation of LocalForward rules
Each LocalForward rule defines a port forwarding configuration from a local port on your machine to a specific RDS instance:
Port 5431 forwards to the development database.
Port 5432 forwards to the QA database.
Port 5433 forwards to the EKS cluster.
π§How to Use the SSH Config File
Using the provided SSH config file is straightforward. Simply save the configuration to your ~/.ssh/config file and replace ~/.ssh/bastion-host.pem with the path to your SSH private key file. Once configured, you can initiate SSH connections to the remote private instances by running βssh rds_tunnel_combinedβ command.
πBenefits and Use Cases
Enhanced security: All connections are encrypted, minimizing the risk of data interception.
Simplified access: Users can easily connect to multiple RDS instances with a single command.
Flexible configuration: The SSH config file allows for easy customization of port forwarding rules to suit different use cases.
Conclusion
SSH tunneling provides a secure and efficient way to access AWS private instances from anywhere. By leveraging SSH config files and port forwarding, you can streamline the process of connecting to multiple RDS instances while ensuring data security. Give it a try and experience the benefits of secure SSH tunneling for yourself!
Thanks for reading my blog. Feel free to hit me up for any AWS/DevOps/Open Source-related discussions.
Manoj Kumar β LinkedIn.