VPS is being more popular day by day. Personally I prefer to use DigitalOcean, they are cheap and their support is awesome. They also have tons of tutorial guides, chat community. Also they answer your questions very quickly in their support forum.
Letâ€™s dive into the main point. When you will have a VPS droplet, you will get an IP, login username, password that you can use to login in your VPS via command line. There are several tools like Putty in windows, but I love to work in command line in Linux or Mac OS.
Letâ€™s assume the IP is 188.8.131.52 where username is root and password is myvps. So, now connect to the VPS using terminal:
If you connect for the first time, the following message could be appeared:
[box type=â€shadowâ€]The authenticity of host â€˜184.108.40.206 (220.127.116.11)â€™ canâ€™t be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?[/box]
Just type yes and press enter. It will ask for password, give the password myvps and press enter, youâ€™re in!
Note that, if you have connected to same VPS using other IP before, then you may see a error message like the following:
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for ras.mydomain.com has changed and you have requested strict checking.
Host key verification failed.[/box]
Then you need to run these commands in terminal, before connecting to VPS:
$ ssh-keygen -R 18.104.22.168
Now we will add new user for your server, as we wonâ€™t use root user. â€œrootâ€ users is only for administrative purpose. Letâ€™s create a new user:
sudo adduser sandbox
Now a user having username as â€˜sandboxâ€™ will be created, but you are not done yet. You will be asked for password immediately. Give password and press enter. Now the system will ask for additional details like name, email etc. You donâ€™t need to provide those information if you donâ€™t want to, just keep pressing enter until you see the following message:
Is the information correct? [Y/n]
Press Y and then press enter. New user â€˜sandboxâ€™ with password (in my case itâ€™s sandbox too) is created!
Now we need to give root privileges to sandbox user:
A text file will be opened in the terminal, add the following lines:
root ALL=(ALL:ALL) ALL
sandbox ALL=(ALL:ALL) ALL
Press â€˜cntrl xâ€™ to exit the file and then â€˜Yâ€™ to save the file.
If you want to delete any user from your system, use the following command:
sudo userdel sandbox
And then you need to delete the userâ€™s home directory:
sudo rm -rf /home/sandbox
To change user: