Skip to content

Instantly share code, notes, and snippets.

@kvahuja
Last active November 27, 2017 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvahuja/d2c927660d00e6f7bcb98b8e030d0693 to your computer and use it in GitHub Desktop.
Save kvahuja/d2c927660d00e6f7bcb98b8e030d0693 to your computer and use it in GitHub Desktop.
Ubuntu Management - Server Setups

User Setup

Add a User

Run the following command to add a new user on a system.

sudo adduser <username>

SUDO access

This is a step that should only be done for any users with sys-admin access.

sudo gpasswd -a <username> sudo

Authorization

All users will only be allowed to access any server using a SSH Key. We have two options to generate and provide key based access.

  • We can ask the users to create their own key pairs and send to us or;
  • We can create a key pair for the user and share the same.

We will go for the later option as the process of generating the key, the methods is something that all users wont be aware off. Also, generating a key pair is something that may need additional software installation which is not preferred as per IT as well.

  1. Login as the user who's SSH key you want to set
su - <username>

This will need you to provide the password for the user.

  1. Generate the Key-Pair
ssh-keygen -t rsa

You will be prompted a set of questions. There is no need to change any values so you can just keep pressing and proceed but if you wish to you can change the values.

  1. Setup the Public Key as part of the User Login
mv .ssh/id_rsa.pub .ssh/authorized_keys
  1. Email the Private key to the user Take the file at the location .ssh/id_rsa and send it across to the user. User will need to use this private key to be able to login.

  2. Set the permissions

chmod 600 .ssh/authorized_keys

Some may say that a sys-admin generating the key pair is not safe. Once the user is able to login into the system, they can (if they want to & know how to) generate a fresh new pair of keys and update their public key at .ssh/authorized_keys thus securing the account.

Change Passwords

If you need to change a user's password you can use the following command

sudo passwd <username>

Once the user logs in to the system they shoudl change their default password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment