Setup of a Server with Debian 12
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:
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
Update
Firewall
sudo aptitude 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 ufw enable # Make sure it's running. sudo ufw status exit # Login again. sudo ufw status
User
SSH
# SSH access for user. # Local machine: ssh-copy-id foo@xx.xx.xxx.xx ssh foo@xx.xx.xxx.xx # Server machine: sudo echo "AllowUsers foo root" >> /etc/ssh/sshd_config sudo sed -i 's/^#TCPKeepAlive .*$/TCPKeepAlive yes/g' /etc/ssh/sshd_config sudo sed -i 's/^.ClientAliveInterval .*$/ClientAliveInterval 600/g' /etc/ssh/sshd_config sudo sed -i 's/^.ClientAliveCountMax *$/ClientAliveCountMax 3/g' /etc/ssh/sshd_config sudo systemctl restart sshd.service exit
Test login:
Alias on local machine:
On client open ~/.ssh/config
, and add:
Editor
This step is optional, but recommended for usability reasons. Feel free to skip this step if you are not a Vim user.