This is a tutorial on server set up and it covers the basics of setting up with Ubuntu 12.04. By the end of this tutorial, you will be able to:
- Set up a new user with root privileges
- Configure SSH for making secure connection
- Access your virtual private server with new user
You can log in as root user but you should have your IP address and root password. As you know, we don’t always use root login for all purposes. Hence an alternative user login to the virtual private server is highly recommended. This tutorial will teach you how to set up a new user for VPS login.
You will see the following on your terminal:
The authenticity of host '220.127.116.11 (18.104.22.168)' can't be established.
ECDSA key fingerprint is 79:95:46:1a:ab:37:11:8e:86:54:36:38:bb:3c:fa:c0.
Are you sure you want to continue connecting (yes/no)?
Enter Yes and type in your root password.
Change of Password
At present, the root password will be the default password that was given you while registering your droplet. You can change the password as you wish.
Creating a New User
You can create a new user for logging into to your VPS. Here, I will be using prinsa as user name. You can change it as you prefer.
For changing the new user’s password, you can use the passwd command as given below:
Once you have set the password for the new user, you may wish to leave rest of the lines like that.
Granting Root Privileges
We need to grant all root privileges for the new user. It’s required for the administrative capabilities in the virtual server. While performing any root tasks with the new user, always remember to use the ‘sudo’ option. This is highly recommended for two reasons:
- It will prevent the user from making any system errors.
- It will store all the commands with ‘sudo’ option in a log file (‘/var/log/secure’) for auditing, in case if needed.
Now, let’s edit the sudo configuration.
Search for the user privilege section and update it with the command to grant all root permissions to the newly created user.
# User privilege specification
root ALL=(ALL) ALL
prinsa ALL=(ALL) ALL
Save and exit the file.
This is optional. Configuring SSH is to make server more secure.
Open the ssh configuration file with this command.
Search for the following section and make the updates wherever necessary.
Here, I have updated the port to 25000. Even though port 22 is the default port, you can change it to any number between 1025 and 65536. However, you need to remember the port number for future log-ins.
Search for PermitRootLogin and change it from ‘yes’ to ‘no’. This will prevent root login in the future. Now you only need to login with the new user.
You can add the following line to the end of the file.
Now the configuration changes are done. Save and exit.
Restart and Reload SSH
You can restart and reload SSH so as to implement the new port and settings.
For verifying the new settings, open a new terminal window and login to your virtual server using the new user and password. Make sure you have not logged out of root yet.
You can include the new port number and you will see the system prompt with your chosen name.
ssh -p 25000 [email protected]
[[email protected] ~]$
You have logged in successfully to your virtual private server with the new user and you can opt to exit out of root now.