Setup of a Server with Fedora 37

/images/2303c098ab27bfbc.jpg

The setup of a Linux server is easy. Just follow the steps given in this tutorial, and you'll have your server up and running, ready to serve your favorite application.

You will see that I won't explain the commands used here. That is to keep it concise and the steps clear. If you have question to a command shown here, your preferred search engine will help you.

Wording

string

meaning

foo

user name

xxxxxxxxx

any string

xx.xx.xxx.xx

IPv4 address

xxxx:xxx:xxxx:xxxx::1

IPv6 address

Prepare SSH key

If there is no SSH key on the local machine yet (unlikely), create an SSH key:

ssh-keygen -t ed25519 -f ~/.ssh/key_ed25519 -b 2048

Install operating system

At your preferred hosting provider, create a new server instance with IPv4 address (SSH with IPv6 might encounter trouble throwing a "Network is unreachable" error), and supply the public SSH key (content of ~/.ssh/key_ed25519.pub) upon server registration.

Connect with server

ssh root@xx.xx.xxx.xx

Update

# Update
sudo dnf update
sudo reboot

Firewall

sudo dnf install ufw

# Make sure it's not running.
sudo ufw status
sudo ufw default allow outgoing
sudo ufw default deny incoming
sudo ufw allow 22

# Start it automatically on boot.
sudo systemctl enable ufw

# Enable it now.
sudo systemctl start ufw

# Make sure it's running.
sudo ufw status
exit

# Login again.
sudo ufw status

User

# Create.
sudo useradd foo
sudo passwd foo

# For administration, ``sudo`` should be used.
sudo usermod -aG wheel foo

SSH

# SSH access for user.
# This file for the root user has been created by the VM creation tool.
# If no ssh key was created during VM setup, then copy the SSH key from
# local machine via ssh-copy-id before continuing.
sudo cp -r ~/.ssh /home/foo
sudo chown -R foo:foo /home/foo/.ssh
sudo echo "AllowUsers foo root" >> /etc/ssh/sshd_config
sudo systemctl restart sshd.service
exit

Test login

  • foo (via SSH)

  • sudo su (on server)

Remote login with password file

On client open ~/.ssh/config, and add:

Host h1
    HostName xx.xx.xxx.xx
    Port 22
    User foo

Editor

This step is optional, but recommended for usability reasons. Feel free to skip this step if you are not a Vim user.

sudo dnf install neovim