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