Skip to content

Instantly share code, notes, and snippets.

@deltqz
Last active September 17, 2025 21:58
Show Gist options
  • Select an option

  • Save deltqz/6967d7b1693c86408434e963d841233a to your computer and use it in GitHub Desktop.

Select an option

Save deltqz/6967d7b1693c86408434e963d841233a to your computer and use it in GitHub Desktop.
SSH Key Wizard

Simple batch script to easily create a SSH key pair and append the public one to the authorized_key file in your local Linux server. Use > to overwrite that file, or >> to append the key to it (default).

It will provide a one-line command to access your server without a password, just copy it and add it to a new profile in Windows Terminal for easy access.

@echo off
title SSH Key Wizard
::Set variables
set user=ubuntu
set ip=10.10.10.10
set keyname=server
::Create an SSH key pair on Windows
cd "C:\Users\%username%\.ssh\"
ssh-keygen -t ed25519 -C "%keyname%" -f "%keyname%" -N ""
::echo
cls & echo SSH key pair generated: %keyname% and %keyname%.pub
::Add the public key to the Ubuntu server's authorized_keys and delete it from Windows
type "%userprofile%\.ssh\server.pub" | ssh %user%@%ip% "cat >> ~/.ssh/authorized_keys"
del "C:\Users\%username%\.ssh\%keyname%.pub"
::echo
cls & echo SSH key pair generated: %keyname% and %keyname%.pub
echo Public key added to %user%@%ip%:~/.ssh/authorized_keys
::Display the SSH connection command
echo.
echo You can now connect to your server using this command:
echo ssh %user%@%ip% -i "%%userprofile%%\.ssh\%keyname%"
echo.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment