azure_ssh.sh 858 字节
Newer Older
J
Jeff Rasley 已提交
1 2 3
#!/bin/bash

config_file=azure_config.json
4 5 6 7 8 9 10 11
if [ ! -f ${config_file} ]; then
    echo "Cannot find $config_file"
    exit 1
fi

location=`cat ${config_file} | jq .location | sed 's/"//g'`
rg=deepspeed_rg_$location

J
Jeff Rasley 已提交
12 13 14 15 16 17 18 19 20 21 22 23
while getopts 'c:' flag; do
  case "${flag}" in
    c) config_file="${OPTARG}" ;;
    *) error "Unexpected option ${flag}" ;;
  esac
done
shift $(expr $OPTIND - 1)
echo "Using $config_file"

nodeid=$1
cmds=${@:2}
echo $nodeid $cmds
24
ip_addr=`az vm list-ip-addresses -g $rg | jq .[${nodeid}].virtualMachine.network.publicIpAddresses[0].ipAddress | sed 's/"//g'`
J
Jeff Rasley 已提交
25 26 27 28 29

ssh_private_key=`cat ${config_file} | jq .ssh_private_key | sed 's/"//g'`
if [ $ssh_private_key == "null" ]; then echo 'missing ssh_private_key in config'; exit 1; fi

ssh -i ${ssh_private_key} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null deepspeed@${ip_addr} ${cmds}