title: Having an issue passing variables to subshell
body: <p>So here is my problem, I have this script I wrote where I'm exporting two variables however they're not making it into the subshell. </p>
  
  <p>The point of this script is to change a users password and clear out their pam_tally for CentOS and Ubuntu hosts. </p>
  
  <p>A little background is that this environment's users are managed by puppet but the passwords are all local, ssh keys are not allowed either (this is set in stone and can't be changed so I have to work with what I got) and the reason is that every log in has to be manual (even number of sessions are limited to two so you can't even user csshX effectively).</p>
  
  <p>Here is my script </p>
  
  <pre><code>    #!/bin/bash
  
  echo "Please enter user whose password you want to change"
  read NEWUSER
  echo "Please enter new password for user"
  read -s -p "Temp Password:" TEMPPASSWORD
  
  PASSWORD=$TEMPPASSWORD
  export PASSWORD
  NEWUSER2=$NEWUSER
  export NEWUSER2
  
  for i in HOST{cluster1,cluster2,cluster3}0{1..9}
  do
  
  ping -c 2 $i &amp;&amp; (echo $i ; ssh -t $i '
  
  sudo pam_tally2 --user=$NEWUSER2 --reset
  
  echo -e "$PASSWORD\n$PASSWORD" | sudo passwd $NEWUSER2
  
  sudo chage -d 0 $NEWUSER2
  
  ')
  
  done
  </code></pre>