title: bash script execute commands after ssh
body: <p>I am trying to execute a few commands via my first script but it's not working.</p>
  
  <pre><code>#!/bin/bash
  
  #connect to server
  echo "Connecting to the server..."
  
  ssh -t root@IP '
  
      #switch user to deploy
      su - deploy
  
      #switch path
      echo "Switching the path"
      cd /var/www/deploys/bin/app/config
  
      #run deploy script
      echo "Running deploy script"
  
      /usr/local/bin/cap -S env=prod deploy
  
      #restart apache
      sudo /bin/systemctl restart  httpd.service
  
      bash -l
  '
  </code></pre>
  
  <p>What is happening? I am successfully connected to the server, the user is changed and then I don't see nothing happening. When I press ctrl + c just like that in terminal, some output from the command that should be executed appears but there are some errors.</p>
  
  <p>Why I don't see everything what is happening in terminal after launching the script? Am I doing it the wrong way?</p>
  
  <p>BTW: when I try connect manually and run the commands myself, everything is working nicely.</p>
  
  <p>Using CentOS 7.</p>