Ask Me About Websites
Menu
  • What is a website?
  • Useful Linux Commands
    • Cheat Sheet of Useful Linux Commands
    • Add / Create New Sudo User
    • 10 Commands to find the processes in Linux
    • Working with Java Keystores
  • Magento Commands
  • Laravel
  • WordPress Tips and Hints
  • What is a website?
  • Useful Linux Commands
    • Cheat Sheet of Useful Linux Commands
    • Add / Create New Sudo User
    • 10 Commands to find the processes in Linux
    • Working with Java Keystores
  • Magento Commands
  • Laravel
  • WordPress Tips and Hints

How to create a new sudo user and secure with SSH key


By paulg | October 9, 2017 | Category Linux Commands, Linux Solutions

Log in to your server as the root user or as yourself if you are a sudo or can become a root user.

ssh root@server_ip_address

or

ssh you@server_ip_address
su
enter su password

Then use the adduser command to create a new user on the system. (replace username with the user that you want to create).

adduser username

Set and confirm the new user’s password at the prompt. A strong password is highly recommended!

Set password prompts:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Follow the prompts to set the new user’s information. It is fine to accept the defaults to leave all of this information blank.

User information prompts:
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:

Is the information correct? [Y/n]

Next you use the usermod command to add the newly created user to the sudo group.

usermod -aG sudo username

By default, on Ubuntu, members of the sudo group have sudo privileges. To test sudo access on new user account, use the switch user command, su, to switch to the new user account.

su - username

Once logged in as the new user, verify that you can use “sudo” to the command, that would require superuser privileges to run. A good test command for example would be to list the contents of the /root directory, which is normally only accessible to the root user.

sudo ls -la /root

Now it is time to add the SSH key. While logged in as the new user go to the home directory for that user and create a SSH directory

mkdir .ssh

Then change to the new directory to add the authorized keys file

cd .ssh

Next create a file called authorized_keys using your favorite file editor – I will use nano.

nano authorized_keys

Paste the contents of the new users public key into the file and save.

Congrats the new user is on the server and secured!

Comments are currently closed.

Recent Posts


  • Add Java Home to a User
  • How to create a new sudo user and secure with SSH key
  • How to config Apache to 301 for HTTP to HTTPS
  • Where do I find the YUI yahooapi serverd secure (https)
  • Fix to Saving Permalinks to fix 404’s

Recent Comments


  • Theron Cashing on Useful Linux Commands
  • check my site on Useful Linux Commands
  • site:forobeta.com/mobidea Mobidea on Useful Linux Commands
  • content on Useful Linux Commands
  • Gerry on Useful Linux Commands

Recent Posts

  • Add Java Home to a User
  • How to create a new sudo user and secure with SSH key
  • How to config Apache to 301 for HTTP to HTTPS
  • Where do I find the YUI yahooapi serverd secure (https)
  • Fix to Saving Permalinks to fix 404’s
  • No space left on device – Could I be running out of Inodes?
  • Simple MYSQL Script to change domain for WP
  • Simple debug setting for WordPress config

Tag Cloud

Pages

  • #552 (no title)
  • 10 Commands to find the processes in Linux
  • Add / Create a new user with SUDO privilegdes to Ubuntu (Linux)
  • Laravel Set Up and Commands Win10
  • Magento Commands
  • test of book
  • TEst of ninja JS
  • Test of WP Google Maps
  • Useful Linux Commands
  • What is a website?
  • WordPress Tips and Hints
  • Working with Java Keystores

Categories

  • Javascript
  • Linux Commands
  • Linux Solutions
  • Wordpress

Copyright © 2020 websidestores.com - askmeaboutwebsites

Theme created by PWT. Powered by WordPress.org