Solve the problem related to 'COMMAND not found' in ssh user @ ip' command '.

Source: Internet
Author: User

Solve the problem related to 'COMMAND not found' in ssh user @ ip' command '.

Environment centos6.5
Status A machine ssh user @ B machine 'command' command to execute the command(Machine B adds trust in machine)
Prompt'bash: node: command not found'

UseSsh user @ B MachineIt is no problem to manually execute the command.echo $PATH;node -vIt is also normal

-Bash-4.1 $ ssh root @ machine B IPLast login: Sat Jun 18 15:14:35 2016 from machine A IP Address [root @ IOS-Account ~] # Echo $ PATH; node-v/data/soft/node/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/sbin:/root/binv4.4.4

UseSsh user @ B machine 'echo $ PATH; node-V'The printed environment variable path is different from the printed path in login mode.

-Bash-4.1 $ ssh root @ B server IP 'echo $ PATH; node-V'/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/sbinbash: node: command not found

According to this article, the cause is found. The environment variables of the following two logon methods are different.ssh user@ipThere will be interactions after loginssh user@ip 'command'After logging on, run the command and exit.

Finally, my solution is:

Ssh root @ B server IP address 'source ~ /. Bash_profile; echo $ PATH; node-v'


-Bash-4.1 $ ssh root @ machine B IP address 'source ~ /. Bash_profile; echo $ PATH; node-v '/data/soft/node/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/sbin:/root/binv4.4.4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.