Setup An Ubuntu Vps Quickly
Setup and secure an Ubuntu VPS Quickly#
Quick guide to setting up a virtual private server quickly
After creating a server
-
Login as root
ssh root@123.123.123.123
-
Update and upgrade
sudo apt update sudo apt upgrade
-
Create a user
adduser newuser
-
Add user to the
sudo
groupusermod -aG sudo newuser
-
Become the new user
sudo su newuser -
-
Create an ssh key
ssh-keygen -t rsa -b 4096 -C “stephen@synergysystems.co.za”
-
logout of the server
exit
-
On your local machine, copy your ssh key to the new user on the server
ssh-copy-id newuser@123.123.123.123
-
Test log in
ssh newuser@123.123.123.123
-
Disable password auth
vim /etc/ssh/sshd_config
set
PasswordAuthentication no
-
Reload ssh
sudo systemctl reload sshd
-
Allow ssh and enable the ufw (uncomplicated firewall) firewall
sudo ufw app list sudo ufw allow OpenSSH sudo ufw enable
Add the server to your ssh config for easy ssh#
vim ~/.ssh/config
Add:
Host newserver
HostName 123.123.123.123
Port 22
User newuser
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Re-source:
source ~/.bashrc
Now you can ssh into the server with:
ssh newserver