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?
which mycommandshould 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:07type mycommandis better thanwhich mycommand, because the former will also look at builtins, functions, and aliases. – l0b0 May 10 '22 at 01:44PATHin~/.bashrcand this act is crucial formycommandto be found. See this answer of mine. Some part of your~/.bashrcmay be omitted in a non-interactive shell started by the SSH server after youssh localhost 'mycommand'. – Kamil Maciorowski May 10 '22 at 15:22