azure_ssh.sh 858 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. config_file=azure_config.json
  3. if [ ! -f ${config_file} ]; then
  4. echo "Cannot find $config_file"
  5. exit 1
  6. fi
  7. location=`cat ${config_file} | jq .location | sed 's/"//g'`
  8. rg=deepspeed_rg_$location
  9. while getopts 'c:' flag; do
  10. case "${flag}" in
  11. c) config_file="${OPTARG}" ;;
  12. *) error "Unexpected option ${flag}" ;;
  13. esac
  14. done
  15. shift $(expr $OPTIND - 1)
  16. echo "Using $config_file"
  17. nodeid=$1
  18. cmds=${@:2}
  19. echo $nodeid $cmds
  20. ip_addr=`az vm list-ip-addresses -g $rg | jq .[${nodeid}].virtualMachine.network.publicIpAddresses[0].ipAddress | sed 's/"//g'`
  21. ssh_private_key=`cat ${config_file} | jq .ssh_private_key | sed 's/"//g'`
  22. if [ $ssh_private_key == "null" ]; then echo 'missing ssh_private_key in config'; exit 1; fi
  23. ssh -i ${ssh_private_key} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null deepspeed@${ip_addr} ${cmds}