Before continuing, your machine needs to have a dedicated domain name that will be its hostname.
You also need to point your app domain names to your machine IP address if you want to host an app for them. See with your domain name registrar to set up A (IPV4) or AAAA (IPV6) records to perform this operation.
A minimal DNS zone typically looks like this:
For example, after that, you will be able to login with:
ssh johndoe@mymachine.example.comInstead of:
ssh johndoe@50.70.150.30Before going any further, you need to generate an SSH key.
ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519Then add it to your server by using:
hostname=mymachine.example.com
userName="johndoe"
ssh "${userName}"@"${hostname}" "echo '$(cat ~/.ssh/id_ed25519.pub)' | tee -a ~/.ssh/authorized_keys > /dev/null"You can also add it to the root account:
ssh -t "${userName}"@"${hostname}" "echo '$(cat ~/.ssh/id_ed25519.pub)' | sudo tee -a /root/.ssh/authorized_keys > /dev/null"By default, Ubuntu comes preinstalled with a non-root sudo user named "ubuntu". The "root" user exists but is not accessible. This is how you are supposed to use your machine, because part of the power inherent with the root account is the ability to make very destructive changes, even by accident.
But you will probably want something more meaningful than "ubuntu" as a username, so you can rename it by using the "root" account (because you can't rename the user you currently logged in).
# Login to your machine's root account
ssh root@"${hostname}"
userName="johndoe"
# Rename user
usermod -l "${userName}" ubuntu
# Rename user group
groupmod -n "${userName}" ubuntu
# Rename home directory
usermod -d /home/"${userName}" -m "${userName}"
# Change password
passwd "${userName}"
# Disconnect from your machine
exitAfter that, you will be able to login with:
ssh johndoe@mymachine.example.comClone this repository:
git clone https://github.com/RomainFallet/server-setup ~/.server-setupRun install script:
bash ~/.server-setup/scripts/install.shReload your .bashrc to make aliases available:
. ~/.bashrcss:self-updatess:recipes:web-machiness:recipes:mail-machiness:recipes:application-machiness:recipes:ci-machiness:recipes:ci-runner-machiness:recipes:file-machiness:recipes:daily-backup-machineClone this repository:
git clone https://github.com/RomainFallet/server-setupInstall dependencies:
npm ciLint markdown and bash files:
npm run lintFormat markdown files!
npm run formatCheck dependencies vulnerabilities:
npm auditInstall latest dependencies patches:
npm update