Skip to content

Instantly share code, notes, and snippets.

@mamun67
Last active November 7, 2018 07:23
Show Gist options
  • Select an option

  • Save mamun67/cfc40875ffec0c9924db6667e361354b to your computer and use it in GitHub Desktop.

Select an option

Save mamun67/cfc40875ffec0c9924db6667e361354b to your computer and use it in GitHub Desktop.
Adding users in Linux
#Create public and private key
#private and public key will be generated
$ ssh-keygen -f name
#Create user
$sudo adduser username --disabled-password
# Change to the new user
sudo su - username
#create a directory
$ mkdir .ssh
#change the permissions
$ chmod 700 .ssh
#Create a new file
$ touch .ssh/authorized_keys
#change the permissions
$ chmod 600 .ssh/authorized_keys
Important
Without these exact file permissions, the user will not be able to log in.
Open the authorized_keys file using your favorite text editor (such as vim or nano).
#copy the public key contents and paste it in the file
$ vim .ssh/authorized_keys
You need to modify the sudo settings to enable password authentication when using sudo. Run the visudo command as root (or sudo visudo) and look for a line like this:
ec2-user ALL=(ALL) NOPASSWD: ALL
Remove the NOPASSWD: bit, so the line looks like this:
ec2-user ALL=(ALL) ALL
sudo will ask for a password next time you log on. Again, make sure to set your password before doing this!
#link:https://brianflove.com/2013/06/18/add-new-sudo-user-to-ec2-ubuntu/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment