summaryrefslogtreecommitdiff
path: root/mksshauth
blob: 4859cac39ae769a5bffe403d480665480a1cde2c (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/bin/mksshauth
  4. # Copyright 2000-2001 Juri Jensen <juri@xenux.dk>
  5. # Copyright 2002 Juri Jensen <juri@xenux.dk> & Jonas Smedegaard <dr@jones.dk>
  6. #
  7. # $Id: mksshauth,v 1.3 2002-12-03 16:35:45 jonas Exp $
  8. #
  9. # Setup local and remote SSH for non-interactive authorization
  10. #
  11. set -e
  12. prg=`basename $0`
  13. keytype=$1
  14. host=$2
  15. case "$keytype" in
  16. 1|rsa1)
  17. keytype=rsa1
  18. id_file=identity.pub
  19. auth_file=authorized_keys
  20. ;;
  21. 2|dsa)
  22. keytype=dsa
  23. id_file=id_dsa.pub
  24. auth_file=authorized_keys2
  25. ;;
  26. rsa)
  27. keytype=rsa
  28. id_file=id_rsa.pub
  29. auth_file=authorized_keys2
  30. ;;
  31. *)
  32. echo "Usage: $prg 1|2|dsa|rsa [user@]host"
  33. exit 1
  34. ;;
  35. esac
  36. [ -f ~/.ssh/$id_file ] || ssh-keygen -t $keytype
  37. ssh $host "mkdir -p ~/.ssh && echo `cat ~/.ssh/$id_file` >> ~/.ssh/$auth_file"