0

When I SSH into a machine I can run a particular command (let's say mycommand) on that machine's bash terminal without issue. BUT when I try to do ssh localhost 'mycommand' I get an "unknown command" error.

Maybe the command is defined in my .bashrc file as an alias but I checked and it isn't.

Any ideas?

neubert
  • 6,863
  • 35
  • 76
  • 138
  • 1
    `which mycommand` should show where the executable is. Sounds like it's in your current path, but not in the path given to ssh shells – Carson May 09 '22 at 22:07
  • 2
    `type mycommand` is better than `which mycommand`, because the former will also look at builtins, functions, and aliases. – l0b0 May 10 '22 at 01:44
  • 2
    Maybe you alter your `PATH` in `~/.bashrc` and this act is crucial for `mycommand` to be found. See [this answer of mine](https://superuser.com/a/1616143/432690). Some part of your `~/.bashrc` may be omitted in a non-interactive shell started by the SSH server after you `ssh localhost 'mycommand'`. – Kamil Maciorowski May 10 '22 at 15:22

0 Answers0