I have created AWS VPC . In that VPC 5 ec2 instances are created, ONLY 1 Instance is publicly accessible other 4 instances are in private network.
i am using script to transfer war file from my local machine to Pubilcly accessible server and then it will transfer to private server .
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 failed to transfer war file from publicly accessible to Private server .
It gives the error:
Host key verification failed!
Script commands :
Transferring from Local machine to publicly accessible server.
scp -p portno -i ./Test.pem ./Test.war ec2-user@publicly_accessible_server_ ip:/home/ec2-user/
Working fine It will transfer local to publicly accessible server.
Transferring from publicly accessible server to Private Server.
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/"
Not able send war files from publicly accessible server to private server gives error Host verification failed**
permission pem file are working .
Note :suppose i run the second command from terminal it works , but in script it is not working !