You are reading content from Scuttlebutt
@Hendrik Peter %TqIZHSpN89eGnYkh6upgRpZELB0NfVx8OAekFZY+Dxo=.sha256
Re: %z0daxWP5r

Forking out with a general tip when it comes to VPCs and root users.

Feel free to ignore this @Giulio Prisco if you already know this :p

I don't see you using sudo in any of your commands, I'd recommend creating a new user once you get access to a VPS that needs to elevate with sudo before being able to run root commands. This to prevent shell scripts and other pieces of code from running as root by default. you can do this like so:

useradd <username> -m --group sudo

where you replace <username> with some inconspicuous username.

passwd <username>

To give your <username> user a password. and then:

sudo chsh -s /bin/bash <username>

To allow your user to login to a bash shell.

(Next step if you connected to the root user using your SSH keys)
You then allow yourself to connect to the new user using ssh by public-key-login by logging in to that user

# Login to that user
su <username> 
# Generate SSH keypair and .ssh folder
ssh-keygen -t rsa
# open the authorized keys file
nano ~/.ssh/authorized_keys

and paste in the public key that sits in ~/.ssh/id_rsa.pub on your own local computer.
(end of special logic that you should do if you logged in to the root user using your public key)

Open up a new terminal tab and see if you can ssh to your brand-spanking new user using:

ssh <username>@<ip-address>

if that succeeds, block people from accessing the root account by going through the following steps:

  • sudo nano in to the /etc/ssh/sshd_config file on your server and make sure to set "permit root login" to "no",
  • Expire the password of your root account (system accounts that have no password can't be logged in to) by executing: sudo passwd -e root

Update your VPS and then restart it for all the changes to take effect ;)

Join Scuttlebutt now