A Python script that deploys your local RSA public key to one or more remote servers in parallel over SSH. Once deployed, you can log in to each server without a password.
- Python 3.10+
- paramiko
Install dependencies:
pip install paramiko
- Copy the example config file and fill in your server details:
cp servers.example.json servers.json
-
Edit
servers.jsonwith the host, port, user, and password for each target server. -
Make sure you have an RSA key pair at
~/.ssh/id_rsa.pub. If you do not have one, generate it:
ssh-keygen -t rsa -b 4096
python index.py
The script connects to all servers concurrently and appends your public key to /root/.ssh/authorized_keys on each one. Example output:
[OK] 192.168.1.10
[OK] 192.168.1.11
[FAIL] 192.168.1.12 - Authentication failed.
servers.json is a JSON array where each object describes one server:
[
{"host": "192.168.1.10", "port": 22, "user": "root", "password": "yourpassword"},
{"host": "192.168.1.11", "port": 22, "user": "root", "password": "yourpassword"}
]- The script is idempotent. Running it multiple times will not duplicate the key.
- After writing the key, permissions are set to
700on~/.sshand600onauthorized_keys. - Deployment tasks run in parallel using a thread pool, so large server lists complete quickly.