title: Preserve sudo environment
body: <p>I'm trying to execute a script from a different server using ssh </p>
  
  <p>Here's the command I'm using from server 1 to launch a query on server 2:</p>
  
  <pre><code>ssh -t user@xxx.xxx.xxx.xx "cd /var/www/vhosts/xxxxx/subdomains/preprod/; sudo ./replace.sh";
  </code></pre>
  
  <p>but the problem is that when I do <code>sudo</code> the <code>$home</code> = <code>/root</code> while the script is under: <code>/var/www/vhosts/xxxxx/subdomains/preprod/</code></p>
  
  <p>How can i tell sudo to preserve the environment?</p>
  
  <p>I tried <code>sudo -P -</code> , <code>sudo -H</code>, without any luck.</p>