How do I add my Windows public key to an existing Linux account?
Transfer only the public key to the intended Linux account and append its single complete line to that account’s authorised-key file. Keep the existing session open until a second session proves the new key works.
Instructions
1. Transfer the public key
An existing authorised login method must already work. This upload does not expose the private key.
scp "$env:USERPROFILE\.ssh\server_ed25519.pub" adminuser@203.0.113.10:server_ed25519.pubThe destination is the account’s home directory. Confirm that the chosen temporary public-key filename will not overwrite another file.
2. Verify the public fingerprint before enrolment
In the existing remote session, confirm that the transferred file contains only the expected public key. Match its fingerprint to your locally generated key, and ensure it is not already enrolled.
ssh-keygen -lf "$HOME/server_ed25519.pub"This read-only check must show the expected public fingerprint before you run the following enrolment block.
install -d -m 700 "$HOME/.ssh"
printf "\n" >> "$HOME/.ssh/authorized_keys"
cat "$HOME/server_ed25519.pub" >> "$HOME/.ssh/authorized_keys"
printf "\n" >> "$HOME/.ssh/authorized_keys"
chmod 600 "$HOME/.ssh/authorized_keys"Run as the intended account. Leading and trailing newlines keep the new key separate even if an existing final line lacked a newline. Blank lines are harmless; existing keys remain in place.
3. Test a second connection
From a new Windows terminal, choose the corresponding private key explicitly.
ssh -o IdentitiesOnly=yes -i "$env:USERPROFILE\.ssh\server_ed25519" adminuser@203.0.113.10Confirm successful login before ending the original session.
Check the result
- The enrolled public fingerprint matches the Windows key.
- A second session authenticates as the intended account using the new key.
Troubleshooting
- The key is ignored
- Check ownership, permissions and any configured alternate authorised-key location.
- SCP cannot authenticate
- Use the existing approved login method or provider key-enrolment mechanism; do not upload the private key.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
