ssh-keygen.tcl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env tclsh
  2. #
  3. # Generate a keypair for SSH encryption.
  4. #
  5. # Copyright 2015-2017 OpenIndex.de.
  6. # Distributed under the MIT License.
  7. # See accompanying LICENSE.txt file or at http://opensource.org/licenses/MIT
  8. #
  9. # initialization
  10. source [file join [file normalize [file dirname $argv0]] init.tcl]
  11. puts ""
  12. puts "========================================================================="
  13. puts " $PROJECT $VERSION: generate SSH keypair"
  14. puts "========================================================================="
  15. puts ""
  16. puts "NOTE: Do not enter a passphrase in order to use the SSH key properly"
  17. puts "within the application!"
  18. puts ""
  19. set KEY_FILE [file join $BASE_DIR "misc" "ssh.key"]
  20. if {[is_windows]} {
  21. set SSH_KEYGEN [file join $SRC_DIR "data" "windows" "openssh" "bin" "ssh-keygen.exe"]
  22. } else {
  23. set SSH_KEYGEN [which "ssh-keygen"]
  24. }
  25. if {$SSH_KEYGEN == "" || ![file isfile $SSH_KEYGEN] || ![file executable $SSH_KEYGEN]} {
  26. puts "ERROR: Can't find the ssh-keygen application!"
  27. exit 1
  28. }
  29. exec [file nativename $SSH_KEYGEN] -t rsa -b 4096 -f $KEY_FILE >@ stdout
  30. puts ""
  31. puts "-------------------------------------------------------------------------"
  32. puts " Your SSH keypair was saved at"
  33. puts " $KEY_FILE"
  34. puts " $KEY_FILE.pub"
  35. puts "-------------------------------------------------------------------------"
  36. puts ""
  37. puts "Provide 'ssh.key' together with the application in order to allow"
  38. puts "encrypted connections through SSH."
  39. puts ""
  40. puts "Put 'ssh.key.pub' into the 'authorized_keys' file on the machine of the"
  41. puts "support staff."
  42. puts ""