Setup
When I offer to create new user, I call it
jack
, you can use any other username.SSH
If it's setup of server, you have to disable ssh with root and allow it with a custom user.
First time connection
ssh root@xxx.xx.xx.xxx
Check IP
/sbin/ip -4 addr
/sbin/ip -6 addr
Update Linux and add new user
apt update
apt upgrade
adduser jack
usermod -aG sudo jack
Enable firewall
sudo apt install -y ufw vim
sudo ufw app list
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status
Copy SSH keys from root to jack
mkdir /home/jack/.ssh/
cp /root/.ssh/authorized_keys /home/jack/.ssh/
chown -R jack:jack /home/jack/.ssh/
chmod -R 700 /home/jack/.ssh/
Exit SSH connection
exit
Connect to server with new user
ssh jack@xxx.xx.xx.xxx
If works, disallow ssh connection with root.
sudo vim /etc/ssh/sshd_config
Find PermitRootLogin
line and replace yes
to no
and restart sshd daemon. Disconnect yourself with exit
and you won't able to connect with root
, connect with custom user now.
/etc/ssh/sshd_config
-PermitRootLogin yes
+PermitRootLogin no
sudo systemctl restart sshd.service
Change root password
sudo -i
passwd
exit