Created
January 16, 2021 07:55
-
-
Save ChlodAlejandro/6e8383baa909d428b9866129a947d5a3 to your computer and use it in GitHub Desktop.
Generate an SSH key, delegate a subdirectory for it, and add it to your SSH agent. Uses ED25519.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo : Configure | |
echo. | |
set /p SSHK_DIR="Subpath: " | |
set /p SSHK_COM="Comment: " | |
echo. | |
if "%SSHK_DIR%" == "" ( | |
goto INVALID | |
) | |
if "%SSHK_COM%" == "" ( | |
set SSHK_COM="%SSHK_DIR%" | |
) | |
echo : Generate | |
echo. | |
mkdir "%USERPROFILE%\.ssh\%SSHK_DIR%" | |
ssh-keygen -t ed25519 -a 100 -C "%SSHK_COM%" -f "%USERPROFILE%\.ssh\%SSHK_DIR%\id_ed25519" | |
if %errorlevel% == 0 ( | |
echo. | |
echo Key created: %USERPROFILE%\.ssh\%SSHK_DIR%\id_ed25519 | |
echo. | |
echo : Add to key store | |
echo. | |
ssh-add "%USERPROFILE%\.ssh\%SSHK_DIR%\id_ed25519" | |
if %errorlevel% == 0 ( | |
echo Added successfully. | |
) else ( | |
echo Issues encountered when attempting to add to key store. Retry manually. | |
) | |
) else ( | |
echo. | |
echo Key creation failed. | |
) | |
goto EXIT | |
:INVALID | |
echo Invalid parameters. Exiting... | |
:EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment