title: Host key verification failed in script
body: <p>I have created AWS VPC . In that VPC <strong>5</strong> ec2 instances are created, <strong>ONLY 1</strong> Instance is publicly accessible other <strong>4</strong> instances are in <strong><em>private network</em></strong>.</p>
  
  <p>i am using script to transfer war file from my <strong>local machine to Pubilcly accessible server and then it will transfer to private server .</strong>  </p>
  
  <p>I am using same pem file all server , so during scp command it will transfer war file from  local machine to publicly accessible server but it will <strong>failed to transfer war file from publicly accessible to Private server</strong> . </p>
  
  <p>It gives the error:</p>
  
  <pre><code>Host key verification failed!
  </code></pre>
  
  <p>Script commands :</p>
  
  <ol>
  <li><p><strong>Transferring from Local machine to publicly accessible server.</strong></p>
  
  <pre><code>scp -p portno -i ./Test.pem ./Test.war ec2-user@publicly_accessible_server_ ip:/home/ec2-user/    
  </code></pre></li>
  </ol>
  
  <blockquote>
    <blockquote>
      <p>Working fine It will transfer local to publicly accessible server.</p>
    </blockquote>
  </blockquote>
  
  <ol start="2">
  <li><p><strong>Transferring from publicly accessible server  to Private Server.</strong></p>
  
  <pre><code> ssh -p portno -i ./Test.pem ec2-user@**publicly accessible server ip** "scp -P portno -i /opt/IdentityFiles/Test.pem /home/ec2-user/Test.war ec2-user@**private_server_ip**:/home/ec2-user/"
  </code></pre></li>
  </ol>
  
  <blockquote>
    <blockquote>
      <p>Not able send war files from publicly accessible server to private server gives error Host verification failed**</p>
    </blockquote>
  </blockquote>
  
  <p>permission pem file are working .</p>
  
  <p>Note :<strong>suppose i run the second command from terminal it works , but in script it is not working !</strong> </p>