Always use passwordless login.
A command should be executed on a remote server via ssh [remote server] [command path]
.
Shell commands should be executed on a remote server via something like
echo [script] | ssh [remote server] "/usr/bin/sh"
in order to control,
which shell is being used.
Alternatively, use something like ssh [remote server] "/usr/bin/sh" << EOF [script] EOF
,
when inline multi line scripts are considered.