Skip to content

ai-help-me/go-ssh-copy-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-ssh-copy-id

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.


Features

  • Multi-host concurrent public key deployment (-c to control concurrency)
  • Password authentication via:
    • Command line (-password PASSWORD)
    • Password file (--password-file FILE)
    • Interactive prompt if neither is provided
  • Supports reading public key from:
    • File (-i option, default ~/.ssh/id_rsa.pub)
  • Automatically creates remote ~/.ssh directory with 0700 permissions
  • 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

Install

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 }}'"

About

A non-interactive tool that replicates the functionality of ssh-copy-id

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages