Linux Shell SSH/No Root One-Liner
Having a scripts for repeatable system administration saves times and reduces human errors. The following lines can be used in shell scripts (I tend to use bash) or in the cloud-init data of a cloud provider. I tend to have this script and the public key of an SSH key in a public Git repo that I just clone into a new VPS and execute. This should work on modern Debian and Red Hat Linux variants such as Ubuntu 22.02 and CentOS (RIP).
18th Dec 2022