Ansible Role to Add SSH Key in-between or to Servers

If you are wondering how can you add your ssh keys to all the servers and these server keys in each other, I have an ansible script for you.

Problem we faced!

We started with only two servers with our first Shopify Application, later it grew to eight and then twelve with number of apps. Now we have over 20+ servers. Sometimes you do inter-communication only to realize that ssh key isn’t added. With every new server, it has to be done all over again – wasting an hour or two. To solve this problem I wrote this small, yet powerful ansible script.


Ansible role Intranet-Access solves this problem.

What it does

  1. It Adds your key in all the servers.
  2. It uploads public keys of all servers in each servers.


ansible-galaxy install VarunBatraIT.intranet-access

Example usage


- hosts: servers
     - { role: VarunBatraIT.intranet-access, USERNAME: "developer" }

ansible-playbook -i inventory.yml ssh-access.yml -kK

Worth Sharing?


  1. I thought someone somewhere must have wrote this go to script for every devops and I found the gold mine. Your blog is a source of a lot of knowledge.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>