Celeb Glow
general | March 14, 2026

How to run a binary from /usr/local/bin with SSH to a MacBook Pro M1 running macOS BigSur (11.2)?

I have installed CMake on my MacBook Pro M1 and have made symbolic link to cmake in /usr/local/bin. I tried different ways to call cmake and check $PATH. Here is a report of all cases:

ssh ali@mac cmake
zsh:1: command not found: cmake
ssh ali@mac <<EOF
cmake
EOF
Pseudo-terminal will not be allocated because stdin is not a terminal.
#output from cmake (it works)
ssh ali@mac
cmake
#output from cmake (it works)
ssh ali@mac echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
ssh ali@mac 'echo $PATH'
/usr/bin:/bin:/usr/sbin:/sbin
ssh ali@mac <<EOF
echo $PATH
EOF
Pseudo-terminal will not be allocated because stdin is not a terminal.
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
ssh ali@mac
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
ssh ali@mac which cmake
cmake not found
ssh ali@mac <<EOF
which cmake
EOF
Pseudo-terminal will not be allocated because stdin is not a terminal.
/usr/local/bin/cmake
ssh ali@mac
which cmake
/usr/local/bin/cmake

Running the command ls -l /usr/local/bin/cmake, no matter direct argument to ssh or heredoc or within ssh connection, gives this output:

lrwxr-xr-x 1 root wheel 42 Mar 25 17:42 /usr/local/bin/cmake -> /Applications/

The software version on my mac:

sw_vers
ProductName: macOS
ProductVersion: 11.2.1
BuildVersion: 20D75

I can't understand why the result of passing command to ssh is different than passing it with heredoc. I also set PermitUserEnvironment PATH in /etc/ssh/sshd_config and restarted the system, it didn't change anything. I didn't create an environment file, because the case that fails to find cmake, already has /usr/local/bin in the $PATH.

5

1 Answer

Thanks to Kenster's comment, I learned I was getting $PATH from my local machine with ssh ali@mac echo $PATH, running ssh ali@mac 'echo $PATH' shows that /usr/local/bin is not part of the path. This answers my misunderstanding above.

I was able to fix the problem by Setting PATH for Mac ssh.

Thanks everyone for valuable feed-backs.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy