Create user with su...
 
Notifications
Clear all

Create user with sudo privileges

Raju
 Raju
(@raju)
Member Admin

Create user with sudo privileges 

 

To create a new user with sudo privileges and add an SSH certificate, follow these steps:

  1. Log in to your Linux machine as the root user.

  2. Run the following command to create a new user called "myuser" with sudo privileges:

useradd -m -G sudo myuser
  1. Set a password for the new user by running the following command:
passwd myuser
  1. Generate an SSH key pair for the new user by running the following command:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
  1. Press enter to accept the default file location and name for the SSH key pair.

  2. Enter and confirm a passphrase for the SSH key pair.

  3. Add the newly created SSH key to the authorized keys file for the new user by running the following command:

cat ~/.ssh/id_rsa.pub >> /home/myuser/.ssh/authorized_keys
  1. Set the correct permissions for the authorized keys file by running the following command:
chmod 600 /home/myuser/.ssh/authorized_keys

With these steps, you should have a new user with sudo privileges and an SSH certificate set up on your Linux machine.

Quote
Topic starter Posted : 04/12/2022 9:51 pm
Topic Tags
Share: