A lightweight Golang tool for distributing SSH public keys to remote hosts.
It supports multi-host concurrency, non-interactive password authentication, and securely appends your public key to the remote ~/.ssh/authorized_keys file.
Unlike the original ssh-copy-id, this tool does not require a local SSH client and does not rely on remote shell commands like cat, echo, or mkdir. The most important thing is the reason for the existence of this software: it does not need to read the password from the terminal. This is a non-interactive tool.
- Multi-host concurrent public key deployment (
-cto control concurrency) - Password authentication via:
- Command line (
-password PASSWORD) - Password file (
--password-file FILE) - Interactive prompt if neither is provided
- Command line (
- Supports reading public key from:
- File (
-ioption, default~/.ssh/id_rsa.pub)
- File (
- Automatically creates remote
~/.sshdirectory with0700permissions - Checks for existing keys to avoid duplicates
- Zero remote command dependency: works even on minimal containers or embedded systems
- Cross-platform: Linux / macOS / Windows / ARM / x86
- Single binary deployment, no extra dependencies
go install github.com/ai-help-me/go-ssh-copy-id@latest
How to use
# copy public key to remote host
/usr/local/bin/go-ssh-copy-id -i ~/.ssh/id_rsa.pub --user root --hosts {{ item }} --password {{ ansible_password }}
# Check ssh connection
ssh -o ConnectTimeout=10 -o BatchMode=yes -o StrictHostKeyChecking=no root@{{ item }} "echo 'SSH connection successful to {{ item }}'"