Capture is var=$(...), as always.
ssh is a bit interesting because it unconditionally invokes a remote shell, so working with completely arbitrary commands (as opposed to simple things like uname -r) requires a different technique:
filename="/path/to/name with spaces/and/ * wildcard characters *"
printf -v cmd_str '%q ' ls -l "$filename"
output=$(ssh "$host" "$cmd_str")
This way you can use arguments with spaces, and they'll be passed with correct quoting through to the remote system (with the caveat that non-printable characters may be quoted with bash-only syntax, so this is only guaranteed to work in cases where the remote shell is also bash).