AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Ubuntu sudo3/19/2023 ![]() ![]() Learn more with our Cloud Server Hosting Product Guide. Let us know below if you have any questions or comments about this task or the Ubuntu distro. If you are logged into your system without a problem then you’ve completed this tutorial perfectly. Open a new terminal window and test your login with: ssh Leave the current session open just in case there’s an issue with the user you’ve created. However, before closing out of this terminal session, let’s test out what we’ve done. You will now be able to log into your Ubuntu server with your new user account, and root user logins through SSH are no longer permitted. Make sure to restart your SSH service: sudo service ssh restart.Change permissions for the authorized_keys file chmod 600 ~/.ssh/authorized_keys.For example, here we area adding a user called h2smedia, the command will be like this. Change your-new-user with whatever name you want to give to your user. Paste your public key into the authorized_keys file Once the sudo is installed, let’s create a new user to use later with the sudo command.ssh directory and create authorized_keys file nano authorized_keys Add sudo to the line that begins with PermitRootLogin: - PermitRootLogin without-password + PermitRootLogin no.Add sudo to the line that begins with AllowGroups: - AllowGroups wheel root + AllowGroups wheel root sudo.Edit the SSH configuration file sudo nano /etc/ssh/sshd_config.Switch to new user (which is still logged in from above) su username.We have full guides on how to create SSH keys you can install on your account for the root user, but adding an SSH key for the user we just created requires a few more steps. Because of this, you must use SSH keys to gain access to your cloud server. Password authentication is automatically disabled to protect your cloud server from brute force password-based cyber attacks. We have now created a user account we can use for every day administrative tasks.īut, in order to access higher level commands, you will need to add the word sudo at the beginning of your command line, for example: $ sudo apt-get update How to Log in with SSH Keys To add the new user to the “sudo” group, run this command as the root user usermod -a -G sudo username.Fill in a secure password and you can skip the other prompts if you want.Run this command as the root user to create the user account useradd username.Log into your server as the root user, replacing “” with your primary domain: ssh.Where necessary below substitute username with the username you want to use on your account. ![]() If you’ve added your SSH key to your account this login will succeed without a password. Note: the first step is completed on your local computer. ![]() For this reason, it is generally considered a best practice to use a unique user account with “superuser”, or, sudo privileges instead of the root account for your regular maintenance and admin tasks.īelow, we will walk you through the whole process of creating the user, adding the necessary privileges, and locking up your root user in the hopes of preventing unwarranted access. But, using the root user can be hazardous: one wrong command can destroy your account. This allows you the option of using the root user for setting up your VPS environment to your individual specifications. install does not produce the installer window. Your cloud server account lets you instantly log in as the most powerful user: root. I have found the same thing with the R2021b installer on Ubuntu 20.04. This article refers to an older version of Ubuntu, please refer to the full guide on how to create a sudo user in Ubuntu 20. Finally, open a new terminal window and run a command that requires root privileges, such as sudo apt-get update.In this article, we’re going to show you how you can create sudo users on your Ubuntu Cloud Server.It is important to add this line at the end of the file, so that the other permissions do not override this directive, since they are processed in order. If you have any sort of syntax problem, visudo will warn you and you can abort the change or open the file for editing again. Replace username with your account username, of course. At the end of the /etc/sudoers file add this line:.You should never edit /etc/sudoers with a regular text editor, such as Vim or nano, because they do not validate the syntax like the visudo editor. Open the /etc/sudoers file (as root, of course!) by running:.Here’s a quick fix that removes the requirement to enter you password for sudo. However, it can also be inconvenient to have to enter your password every time that you use sudo. You probably know that in Ubuntu/Debian, you should not run as the root user, but should use the sudo command instead to run commands that require root privileges. ![]()
0 Comments
Read More
Leave a Reply. |