title: How to use ssh to run a local .sh file (present on a local linux machine) on a remote linux machine (an AWS ec2 instance)
body: <p>I am having a tough time figuring out a way to execute a .sh file present on my local linux machine on to a remote linux machine which happens to be an AWS ec2 instance.
  Here's what I am doing on my local machine:</p>
  
  <pre><code>ssh -i sample.pem ec2-user@server_name.amazon.com 'bash -s' &lt; file_to_remotely_execute.sh
  </code></pre>
  
  <p>Error that I get is:</p>
  
  <p><em>Warning: Identity file sample.pem not accessible: No such file or directory.
  Pseudo-terminal will not be allocated because stdin is not a terminal.
  Host key verification failed.</em></p>
  
  <p><a href="https://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-shell-script-on-a-remote-machine">This</a> was referred to arrive at the above approach.</p>