Skip to content

Instantly share code, notes, and snippets.

@0187773933
Created July 30, 2020 10:04
Show Gist options
  • Save 0187773933/52396b6d07ed3d49a221b4bc012ea7d2 to your computer and use it in GitHub Desktop.
Save 0187773933/52396b6d07ed3d49a221b4bc012ea7d2 to your computer and use it in GitHub Desktop.
Windows SSH into Wherever with Temporary Private Key as Single Command No ssh-agent
Windows SSH into Wherever with Temporary Private Key as Single Command No ssh-agent
WindowsSSHViaTempKey.batch
#1.) Store SSH Private Key in file on unix
#2.) Cat the file into hex bytes
cat private_key_file | od -A n -t x1
or
cat private_key_file | od -vt x1 | awk '{$1="";print}' | awk '{ gsub(/ /,""); print }'
* remove all spaces from hex string
#3.) Replace the string here , no new lines, don't even try it.
echo randomhexbyteprivatekeystringthatendsin0a > private_key_test.txt && ^
certutil -f -decodehex private_key_test.txt private_key_test >nul && ^
del private_key_test.txt && ^
ssh -i private_key_test ssh_user@ssh_ip_address ^
-o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o IdentitiesOnly=yes ^
-o StrictHostKeyChecking=no ^
-o LogLevel=ERROR && ^
del private_key_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment