Command not found via ssh with single command, fou

2019-02-05 20:21发布

Possible Duplicate:
Why does an SSH remote command get fewer environment variables then when run manually?

If I put command

ssh user@$IP ant

then I receive

bash: ant: command not found

but when I log into

ssh user@$IP

and put

ant

then work fine.

Ant is installed on remote and local machines. Where is the problem?

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.

标签: linux ssh
2条回答
够拽才男人
2楼-- · 2019-02-05 20:49

Specify the absolute path to ant, if I recall correctly your profile doesn't get run when you run a remote ssh command.

查看更多
Viruses.
3楼-- · 2019-02-05 21:11

By default profiles aren't loaded when connecting via ssh. To enable this behaviour, set the following option in /etc/ssh/sshd_config:

PermitUserEnvironment yes

afterward restart ssh

/etc/init.d/ssh restart
查看更多
登录 后发表回答