I would say this:
sshpass -p XXXX ssh -oStrictHostKeyChecking=no wsuser@192.168.0.100 \
"sudo docker exec -u postgres postgres-container \
/bin/bash -c \"psql -d crawl-configuration -c 'select * from schema_version'\""
Double quote the whole command to be executed by ssh, then escape double quotes within the command.
Alternatively, use a here-doc:
sshpass -p XXXX ssh -T -oStrictHostKeyChecking=no wsuser@192.168.0.100 <<-'EOF'
sudo docker exec -u postgres postgres-container \
/bin/bash -c "psql -d crawl-configuration -c 'select * from schema_version'"
EOF
No quoting needed because of the quoted 'EOF'
delimiter. The -T
disables allocation of a pseudo-terminal.