157 words
1 minutes
How to Use ssh-copy-id on Windows with WSL

Introduction#

When I needed to set up SSH public key authentication from Windows to Ubuntu for my research, I found that the ssh-copy-id command wasn’t available natively. This guide shows how to use ssh-copy-id through WSL to register your public key on a server.


Prerequisites#

  • WSL is installed on Windows
  • You can reach the server with ssh user@host

Steps#

1. Launch WSL#

wsl

Run the following commands inside WSL.


2. Prepare SSH Keys#

mkdir -p ~/.ssh
chmod 700 ~/.ssh

Create a New Key#

ssh-keygen -t ed25519 -f ~/.ssh/key
  • Private key: ~/.ssh/key
  • Public key: ~/.ssh/key.pub

Use an Existing Windows Key#

Copy your Windows SSH key to WSL:

cp /mnt/c/Users/YourUsername/.ssh/id_ed25519 ~/.ssh/key
cp /mnt/c/Users/YourUsername/.ssh/id_ed25519.pub ~/.ssh/key.pub
chmod 600 ~/.ssh/key

Replace /mnt/c/Users/YourUsername/ with your actual Windows home directory. Adjust the key filename as needed.


3. Register Public Key on Server#

ssh-copy-id -i ~/.ssh/key.pub user@host

You’ll be prompted for a password on the first connection.


4. Verify Connection#

ssh -i ~/.ssh/key user@host

If you can connect without a password, you’re done.


To skip the -i option every time, set up SSH config.
How to Set Up SSH Config

How to Use ssh-copy-id on Windows with WSL
https://naonao-na.com/en/posts/ssh-copy-id-windows/
Author
[object Object]
Published at
2025-12-10