ssh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname $0)/..
  4. chmod 0600 ./assets/rancher.key
  5. QEMU=1
  6. UNAME=$(uname)
  7. INTERACTIVE="-it"
  8. while [ "$#" -gt 0 ]; do
  9. case $1 in
  10. --name)
  11. shift 1
  12. NAME="$1"
  13. ;;
  14. --notty)
  15. INTERACTIVE=""
  16. ;;
  17. --qemu)
  18. QEMU=1
  19. ;;
  20. --qind)
  21. QIND=1
  22. QEMU=0
  23. ;;
  24. --key)
  25. shift 1
  26. KEY="$1"
  27. ;;
  28. *)
  29. break
  30. ;;
  31. esac
  32. shift 1
  33. done
  34. if [ "$QEMU" == "1" ]; then
  35. exec ssh -p 2222 -F ./assets/scripts_ssh_config -i ${KEY:-./assets/rancher.key} rancher@localhost "$@"
  36. elif [ "$QIND" == "1" ]; then
  37. NAME=${NAME:-ros-qind}
  38. if [ -n "$KEY" ]; then
  39. docker inspect ${NAME} >/dev/null 2>&1 || exit 1
  40. docker cp ${KEY} ${NAME}:/stuff/$(basename ${KEY})
  41. KEY_FILE=/stuff/$(basename ${KEY})
  42. fi
  43. exec docker exec ${INTERACTIVE} ${NAME} /ssh.sh -i ${KEY_FILE:-/stuff/rancher.key} rancher@localhost "$@"
  44. else
  45. exit 42
  46. fi