|
||
---|---|---|
.gitignore | ||
Readme.html | ||
Readme.md |
Readme.md
Mastodon instance setup instructions
Part 1: Creating & accessing the server
Prerequisites
- Linux/Unix terminal environment (Linux, Mac, or Windows Subsystem for Linux).
- Password manager (e.g. OnePassword) installed & setup.
Steps
-
Register a new VPS. 4GB RAM & 2 CPU cores is recommended, but 2GB/1 core will work for a small instance. Install the LTS version of Ubuntu Server ("20.04 LTS", at time of writing). Take note of the IP or domain name provided to you for it by the hosting provider.
-
Think up a name for your server (as distinct from the name of the mastodon instance it will host). This sounds silly but helps a lot with remembering things.
-
Decide on a username you will use to administer the server. It can be anything as long as it’s not ‘root’.
-
Open a terminal.
-
Make sure you know your package manager. On Mac this would be homebrew (3rd party) (see https://brew.sh) on Ubuntu/Debian/WSL it would be apt.
-
Install up-to-date openssh package with your package manager:
sudo apt install openssh
ORbrew install openssh && brew link openssh
-
Generate a new SSH key for accessing your server
ssh-keygen -t ecdsa -f ~/.ssh/{serverUsername}@{servername}_ecdsa
- Follow the prompts, adding a passphrase. Store the passphrase in your password manager. This may seem like a convoluted process to use a password to log in the the server like you can just do anyway, but I promise it’s tons more secure — you need both the password and the secret key file we’re creating.
-
SSH into your server with the temporary root account & password
ssh root@{server domain or IP}
-
Now you’re logged in, create the user you’ll be using from now to administer.
adduser {serverUsername} sudo
- Follow the prompts but leave the random fields as default/blank. Set a randomly generated secure password, and also store it in a password manager.
-
Exit SSH with
exit
-
Upload your new authentication key:
ssh-copy-id {serverUsername}@{server domain/IP} ~/.ssh/{the key you made}
- When asked for a password, provide the one you just created recently, not the root one.
-
Test that public key authentication works.
ssh {serverUsername}@{server} -i ~/.ssh/{key file}
- You should be asked for the key passphrase, and not the login password for the user. Yay, secure authentication!
exit
from the server again.
-
Open ~/.ssh/config in a code editor
-
touch ~/.ssh/config
-
chmod 600 ~/.ssh/config
-
Open the file in a code editor and insert the following:
Host {server name (not domain)} HostName {server domain/IP} IdentityFile ~/.ssh/{key file} User {serverUsername}
-
-
Try to SSH using the new host config:
-
ssh {servername}
-
Now we’ve confirmed you can effectively log in as your custom user with SSH key, it’s time to disable SSH password authentication and root user login. This protects you from 99% of hacking attempts.
- Still on the server, open /etc/ssh/sshd_config in a command line editor such as
nano
orvim
. - Find the line with
PasswordAuthentication
and change the value tono
, making sure it’s not commented out. - Find the line with
PermitRootLogin
and change that tono
as well.
- Still on the server, open /etc/ssh/sshd_config in a command line editor such as
-
Run
systemctl restart ssh
. You will be disconnected by the server. -
Re-SSH into the server to show that it still works with only public key authentication.