{"id":18947650,"url":"https://github.com/yousafkhamza/deploy-key","last_synced_at":"2025-04-15T23:30:23.954Z","repository":{"id":195965537,"uuid":"373985049","full_name":"yousafkhamza/deploy-key","owner":"yousafkhamza","description":"This is a simple localhost playbook and this playbook works with your AWS IAM user access/secret key. Furthermore, the playbook's actual working is like deploying the same SSH key to all or multiple regions. So, then whether we can use the same key which we used regions so no need to store multiple keys.","archived":false,"fork":false,"pushed_at":"2021-07-11T09:11:19.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-09-20T19:52:40.049Z","etag":null,"topics":["ansible","aws","playbook","ssh"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yousafkhamza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-06-05T00:04:26.000Z","updated_at":"2023-09-20T19:52:45.672Z","dependencies_parsed_at":"2023-09-20T20:13:33.988Z","dependency_job_id":null,"html_url":"https://github.com/yousafkhamza/deploy-key","commit_stats":null,"previous_names":["yousafkhamza/deploy-key"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdeploy-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdeploy-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdeploy-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdeploy-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yousafkhamza","download_url":"https://codeload.github.com/yousafkhamza/deploy-key/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223688710,"owners_count":17186298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","aws","playbook","ssh"],"created_at":"2024-11-08T13:10:49.440Z","updated_at":"2024-11-08T13:10:52.140Z","avatar_url":"https://github.com/yousafkhamza.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# A SSH Key Deploy to Multiple Regions.\n[![Builds](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)\n\n---\n## Description\nThis is a simple localhost playbook and this playbook works with your AWS IAM user access/secret key. Furthermore, the playbook's actual working is like deploying the same SSH key to all or multiple regions. So, then whether we can use the same key which we used regions so no need to store multiple keys.\n\n---\n## Features:\n- Easy to Deploy an SSH-Key to multiple regions in AWS\n- SSH-Key is creating with the same script.\n- Multiple regions were using the same key so we don't store multiple key's\n- If your installing ansible along with python2 you don't need to install any dependencies to connect AWS from local\n\n---\n## Pre-Requests \n- Install Ansible on your Master Machine (_localhost_)\n- Create an IAM user role under your AWS account and please enter the values once the playbook running time\n##### Installation\n[Ansible2](https://docs.ansible.com/ansible/2.3/index.html) (For your reference visit [How to install Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html))\n##### IAM Role Creation\n[IAM Role Creation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create.html)\n##### Ansible Modules used\n- [yum](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html) \n- [pip](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/pip_module.html)\n- [openssh_keypair](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssh_keypair_module.html)\n- [shell](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html)\n- [ec2-key](https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_key_module.html)\n---\n\n### How To Use\nAnsible Installation article is in the pre-request section so please check out the pre-request section.\n```sh\namazon-linux-extras install -y ansible2\nyum install git -y\ngit clone https://github.com/yousafkhamza/deploy-key.git\ncd deploy-key\n# --------------------------------------\n# --- Please-Change-Your-Credentials ---\n# --------------------------------------\nansible-playbook main.yml\n```\n---\n## Behind the Playbook.\nI just pasted the main.yml \n\n```sh\n---\n- name: Creating key on multiple location\n  hosts: localhost\n  vars_files:\n    - cred.vars\n  vars:\n    key_name: \"id_rsa\"    \u003c-------------------------- Key Name.\n  tasks:\n  # ---------------------------------------------------------\n  # Lets Start the Task\n  # ---------------------------------------------------------\n    - name: \"Creating New SSH-Kay Meterial\"\n      run_once: True\n      openssh_keypair:\n          path: \"{{ key_name }}\"\n          type: rsa\n          size: 4096\n          state: present\n\n    - name: \"Renaming Local Private Key\" \n      run_once: True\n      delegate_to: localhost\n      shell: \"mv ./{{ key_name }}  ./{{ key_name }}.pem\"\n          \n    - name: \"Creating Key pair\"\n      ec2_key:\n        access_key: \"{{access_key}}\"\n        secret_key: \"{{secret_key}}\"\n        region: \"{{item}}\"\n        name: \"{{key_name}}\"\n        key_material: \"{{ lookup('file', './{{key_name}}.pub') }}\"\n        state: present\n      with_items:           \u003c----------------- Please add which you needed regions \n        - ap-south-1\n        - us-east-2\n        - us-west-2\n```\nPlease change the credential with your AWS IAM Access key.\n```sh\naccess_key: \"\u003cYour access key\u003e\"\nsecret_key: \"\u003cYour secret key\u003e\"\n```\n---\n## Additional Reference \nAWS Region List. [Region List](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html)\n\n## Architacture\n- _Architacture_\n\n![alt text](https://i.ibb.co/B23ZqwR/strucutre.jpg)\n\n---\n# Conclusion\nThe playbook's actual working is like deploying the same SSH key to all or multiple regions. So, then whether we can use the same key which we used regions so no need to store multiple keys.\n\n\n### ⚙️ Connect with Me\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"mailto:yousaf.k.hamza@gmail.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Gmail-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://www.instagram.com/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge\u0026logo=instagram\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://wa.me/%2B917736720639?text=This%20message%20from%20GitHub.\"\u003e\u003cimg src=\"https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white\"/\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fdeploy-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyousafkhamza%2Fdeploy-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fdeploy-key/lists"}