The obvious answer, "install the command on the remote machine",
is the most clean solution, so we should not ignore it:
If this is possible to install the command as root, for example with
sudo apt-get install fish
,
the command can be run like this:
ssh remote -t fish
The question is about what to do when we can not install a command on the remote computer.
Or more specific, it is about the case we can not install a command as root.
That does not mean we can not install at all!
What is still possible is to install the command inside the home directory by building it from the source.
This has the advantage that it takes care of all the associated support files that may come with a command, and how the programm finds them. In the fish
shell example, these are the completion functions etc, all not available if we just copy the fish
binary.
Building a command from source needs development tools and development files of the used libraries, which may be too complicated.
But many programs come with all what they need bundeled in the sources, so it may be easy. Hard to tell before, but one can just try.
To install a command into the home directory, configure
is supplied with the path to install to - that need to be checked in the build instructions. Eg:
mkdir ~/local
./configure --prefix=~/local
make
make install
Note it's not sudo make install
as usual - as it's the whole point of installing it locally to not need sudo here.
For general information on installing programs from source, see askubuntu.SE: How do I install a .tar.gz (or .tar.bz2) file?