Skip to main content

ssh-keyup

CI PyPI Python Platform

Set up passwordless SSH in one command on any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers.

Tired of juggling ssh-keygen, ssh-copy-id (missing on Windows) and ~/.ssh/config edits every time you set up a new device?

ssh-keyup handles all three in one interactive session.

One ssh-keyup session setting up a Raspberry Pi, then ssh to mypi alias logging in with no password.

Quickstart

Needs Python 3.8+ and OpenSSH tools (ssh, ssh-keygen) in PATH:

  • Windows 10/11: Python from python.org or Microsoft Store. OpenSSH Client via Settings > Optional Features or Git for Windows.
  • Linux: sudo apt install python3 openssh-client (usually pre-installed).

Install with pipx:

pipx install ssh-keyup

ssh-keyup   # ready to use anywhere

pip install ssh-keyup works too. Add any folder it warns about to PATH.

Or run directly without installing:

git clone https://github.com/Kurokesu/ssh-keyup.git
cd ssh-keyup
python ssh_keyup.py   # Windows
python3 ssh_keyup.py  # Linux

Follow prompts, enter remote password once and you're done. Alias now works in anything that reads ~/.ssh/config:

Terminal:

ssh mypi   # no password, ever again

VS Code: Remote - SSH works out of the box. Press Ctrl+Shift+P, select Remote-SSH: Connect to Host and pick your alias for a full IDE on the device, no password:

VS Code connecting to the mypi alias over Remote SSH without a password.

Usage

Skip prompts

ssh-keyup pi@192.168.1.23 mypi        # user, host and alias in one go
ssh-keyup pi@192.168.1.23:2222 mypi   # non-default SSH port
ssh-keyup admin@192.168.88.1 router   # RouterOS, detected automatically

Flags (--host, --user, --alias, --port, --os, --key-type) work too, see ssh-keyup --help

Set up a fleet

for host in 192.168.1.10 192.168.1.11 192.168.1.12; do
  ssh-keyup pi@$host
done

Manage entries

List or remove entries ssh-keyup manages:

ssh-keyup --list
ssh-keyup --remove mypi   # deletes its key pair too

How it works

                    local                        remote
check connection    -------- SSH port -------->  sshd
generate key        ~/.ssh/id_ed25519_mypi
deploy public key   -------- public key ------>  ~/.ssh/authorized_keys
update ssh config   ~/.ssh/config

Features

  • Works on Windows OpenSSH, where ssh-copy-id does not exist
  • Never touches your password. Only the public key is piped over SSH and OpenSSH prompts for the password itself
  • Separate key per device (~/.ssh/id_ed25519_<alias>), Ed25519 by default or RSA with --key-type rsa
  • Deploys in a single SSH session, one password prompt total
  • Replaces existing key only after device confirms new one, failed runs leave key and config as they were
  • Adds a named entry to ~/.ssh/config, works instantly with ssh <alias> and VS Code Remote SSH
  • Checks host is reachable first, so typos surface before keys exist
  • Detects RouterOS and imports the key its way
  • Recovers from host key mismatches and stale SSH config entries after a reflash
  • Entry management, list or retire devices without leaving stale keys behind
  • Zero dependencies, standard library plus system OpenSSH

Security

Whole tool is one file, ssh_keyup.py. Keys, logins and host checks go through system OpenSSH:

  • Private key stays local, only public key reaches remote
  • OpenSSH asks for password itself, ssh-keyup does not read it
  • Unknown or changed host key shows its fingerprint and waits for confirmation
  • Locally changes only alias key pair, its ~/.ssh/config entry and known_hosts
  • On remote adds one line to ~/.ssh/authorized_keys, or one /user/ssh-keys entry on RouterOS
  • No telemetry, connects only to remote host
  • Keys carry no passphrase. Add one with ssh-keygen -p -f ~/.ssh/id_ed25519_<alias>

Every PyPI release is built and uploaded by this repository's release workflow through Trusted Publishing, with signed attestation. Verify a download against this repository:

pipx run pypi-attestations verify pypi --repository https://github.com/Kurokesu/ssh-keyup pypi:ssh_keyup-<version>-py3-none-any.whl

Report vulnerabilities privately, see security policy.

FAQ

How do I set up passwordless SSH from Windows by hand?

Usual commands:

ssh-keygen -t ed25519
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh pi@raspberrypi.local "cat >> ~/.ssh/authorized_keys"
notepad $env:USERPROFILE\.ssh\config   # then add a Host block by hand

Works once. Same key lands on every device, ~/.ssh keeps default permissions that sshd may reject and each new device means another config edit.

Is there ssh-copy-id for Windows?

Not built in. Windows OpenSSH does not ship it and RouterOS has no authorized_keys for it to append to. ssh-keyup covers both as an ssh-copy-id alternative:

ssh-keyup ssh-copy-id
Works on Windows OpenSSH yes no
Works with RouterOS yes no
Separate key per device yes no
Sets authorized_keys permissions yes yes
Writes ~/.ssh/config alias yes no
Recovers from changed host key yes no
Entry management yes no

How do I fix "REMOTE HOST IDENTIFICATION HAS CHANGED"?

Reflashing creates a new host key, so next ssh refuses to connect:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
...
Offending ECDSA key in ~/.ssh/known_hosts:3
Host key verification failed.

Run ssh-keyup again. It detects a changed key, shows new fingerprint for confirmation, clears stale known_hosts entry with ssh-keygen -R and redeploys. Usually a reflash is behind it, but this warning can also mean a real man-in-the-middle, so ssh-keyup asks instead of trusting silently.

Does --remove clean up entries on the device?

No. It deletes local key pair and ~/.ssh/config entry. Line in the device's authorized_keys (or /user/ssh-keys entry on RouterOS) stays until removed there. Same goes for old key after regenerating a key pair.

What devices are supported?

Any Linux device reachable over SSH: Raspberry Pi, NVIDIA Jetson, Orange Pi, VMs, servers. Any distribution works (Raspberry Pi OS, DietPi, Ubuntu and others). Any RouterOS 7.12 or newer device, MikroTik routers or CHR alike, is detected from SSH banner and gets its own key import, --os routeros forces it.

Can I use an RSA key instead of Ed25519?

Yes. --key-type rsa generates a 4096-bit RSA key for devices or policies that will not take Ed25519. Keys carry their type in the name, id_ed25519_mypi or id_rsa_mypi, so switching type for an alias leaves the old key alone and ssh-keyup offers to delete it once device confirms new one.

How do I add an SSH key to a MikroTik router from Windows?

By hand on RouterOS 7:

ssh-keygen -t ed25519
scp $env:USERPROFILE\.ssh\id_ed25519.pub admin@192.168.88.1:
ssh admin@192.168.88.1 "/user/ssh-keys/import public-key-file=id_ed25519.pub user=admin"

Works, with two password prompts and the default key shared across devices again. ssh-keyup admin@192.168.88.1 router does it in one session with one prompt, RouterOS is detected from SSH banner. Login user needs policy permission (full group has it) and firmware 7.12 or newer, older RouterOS rejects Ed25519 keys with unable to load key file (wrong format or bad passphrase).

Why does RouterOS refuse my password over SSH after adding a key?

That is the default: once a user has a key, RouterOS stops accepting that user's password over SSH. WinBox and WebFig are unaffected. /ip/ssh/set password-authentication=yes turns password SSH back on (always-allow-password-login=yes on 7.20 and older).

Same default stops ssh-keyup from adding a second key for that user by password. Remove first key under System > Users > SSH Keys in WinBox or WebFig, then run again. Running again for an alias whose key is still in ~/.ssh needs no password, ssh-keyup logs in with that key.

Metadata

Release files for ssh-keyup 1.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssh-keyup 1.4.2
File Size Uploaded Provenance Actions
ssh_keyup-1.4.2.tar.gz 32.1 kB With provenance Details for ssh_keyup-1.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ssh-keyup 1.4.2
File Interpreter ABI Platform Actions
ssh_keyup-1.4.2-py3-none-any.whl Python 3 none any Details for ssh_keyup-1.4.2-py3-none-any.whl

Total release size: 64.4 kB

Release files / ssh_keyup-1.4.2.tar.gz

Download URL ssh_keyup-1.4.2.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
17f6114f777d9cde41a39ba49f6006b44b26676d7be264668d1213cf67033050
BLAKE2b-256 checksum
How to use checksums
8434adcfe30e3eb2e526844a1894aa257e49ecaf0d7cc7c09204115a23df071f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / ssh_keyup-1.4.2-py3-none-any.whl

Download URL ssh_keyup-1.4.2-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
987a89c2b830a7b9e574b685b90887a41bab9671ce5d17124d2f07dbf7379302
BLAKE2b-256 checksum
How to use checksums
0616614f32b886e4f72df6d2d5cede71df83f087c469ff22cc426b743d4fcd68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for ssh-keyup 1.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ssh_keyup-1.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page