Notifications
Clear all
Create user with sudo privileges
To create a new user with sudo privileges and add an SSH certificate, follow these steps:
-
Log in to your Linux machine as the root user.
-
Run the following command to create a new user called "myuser" with sudo privileges:
useradd -m -G sudo myuser
- Set a password for the new user by running the following command:
passwd myuser
- Generate an SSH key pair for the new user by running the following command:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
Press enter to accept the default file location and name for the SSH key pair.
-
Enter and confirm a passphrase for the SSH key pair.
-
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
- 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.
Topic starter
Posted : 04/12/2022 9:51 pm