Remote access the server as root
ssh root@<ip_address>
Enter the password and you are in. Of course, you need to know the password to begin with. The hosting provider that you purchased the VPS from should have securely provided this to you.
To change root’s password do
passwd root
And enter a new password.
Add a new user
useradd -s /bin/bash -m -c "Jimmy Sweeney" -G sudo sweenejp
- -s /bin/bash: The shell option. This sets the default shell for this new user
- -m: The make home directory option. This creates a directory in the “/home/” directory, with the same name as the new user account name.
- -G sudo: adds the user to the sudo group which grants them root privileges when using ther command
sudo
- -c “Jimmy Sweeney”: The full name of the new user. This is optional.
- sweenejp: The name of the new user account. This must be unique. It cannot already be in use for another user.
Then set a password with
passwd sweenejp
Remote acces the server with an ssh key
Exit the server. Then create an ssh key if one does not already exist. Copy the public ssh key to the remote server with
ssh-copy-id sweenejp@<ip_address>
You could do the same with root but I plan on using the sweenejp
user at this point on anyway.
Now you should be able to ssh into the server without having to enter a password each time.
ssh sweenejp@<ip_address>