Command not found via ssh with single command, fou

2019-02-05 20:49发布

问题:

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.

回答1:

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


回答2:

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



标签: linux ssh