How to run commands over SSH with sudo

Categories:
  1. With password in command line (insecure):
    1ssh -tt "$username@$hostname" echo "$password" \| sudo -S -- command
  2. With password prompted:
    1ssh -tt "$username@$hostname" cat <<END \| sudo -S -- command