ssh -t user@server sudo -- "sh -c 'apt update && apt upgrade -y'" # For example, ec2 Debian or Ubuntu Linux server can be updated as follows ssh -t ls.www-2 sudo -- "sh -c 'apt update && apt upgrade -y'"