Linux 使用单个命令通过 ssh 找不到命令,在连接到终端后找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10562722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Command not found via ssh with single command, found after connecting to terminal
提问by Marek Bardoński
Possible Duplicate:
Why does an SSH remote command get fewer environment variables then when run manually?
If I put command
如果我把命令
ssh user@$IP ant
ssh 用户@$IP 蚂蚁
then I receive
然后我收到
bash: ant: command not found
bash: ant: 命令未找到
but when I log into
但是当我登录时
ssh user@$IP
ssh 用户@$IP
and put
并放
ant
蚂蚁
then work fine.
然后工作正常。
Ant is installed on remote and local machines. Where is the problem?
Ant 安装在远程和本地机器上。问题出在哪儿?
I've tried to find solution in google and found nothing.
我试图在谷歌中找到解决方案,但一无所获。
Thanks in advance for help!
预先感谢您的帮助!
--EDIT--
- 编辑 -
I need to invoke some bash scripts, don't want to change all paths to full path.
我需要调用一些 bash 脚本,不想将所有路径更改为完整路径。
采纳答案by Chris Montanaro
By default profiles aren't loaded when connecting via ssh. To enable this behaviour, set the following option in /etc/ssh/sshd_config:
默认情况下,通过 ssh 连接时不会加载配置文件。要启用此行为,请在 /etc/ssh/sshd_config 中设置以下选项:
PermitUserEnvironment yes
afterward restart ssh
然后重启ssh
/etc/init.d/ssh restart
回答by Benj
Specify the absolute path to ant
, if I recall correctly your profile doesn't get run when you run a remote ssh
command.
指定到 的绝对路径ant
,如果我没记错的话,当您运行远程ssh
命令时,您的配置文件不会运行。