开发者

Preserve sudo environment [duplicate]

This question already has answers here: Why does sudo change the PATH? [closed] (18 answers) Closed 3 years ago.

I'm trying to execute a script from a different server using ssh

Here's the command I'm using from server 1 to launch a query on server 2:

ssh -t user@xxx.xxx.xxx.xx "cd /var/www/vhosts/xxxxx/subdomains/preprod/; sudo ./replace.sh";

but the problem is that when I do sudo the $home = /root while the script is under: /var/www/vhosts/xxxxx/subdomains/preprod/

How can i tell sudo to preserve the environment?

I tried开发者_Go百科 sudo -P - , sudo -H, without any luck.


That's what I got from the man page.

sudo -E

-E The -E (preserve environment) option will override the env_reset option in sudoers(5)). It is only available when either the matching command has the SETENV tag or the setenv option is set in sudoers(5).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜