I'm running running ssh commands from client machine on a remote machine:
ssh -o "StrictHostKeyChecking no" -i $key 'user'@$public_ip "
i=1;
workerips: "ip1 ip2";
for ip in $worker_ips; do
echo \"ipis: ${ip} and i is ${i}\"
done;"
My problem is that '$ip' and '$i' are empty inside the 'for' loop. '$i' keeps its value outside the for loop. What am I doing wrong?
workips="ip1 ip2";? Actually, you probably need to escape those quotes:workerips=\"ip1 ip2\";. You probably also need to escape each$to\$so that it's interpreted on the remote machine rather than locally.