Metakgp:SysAdmin/Create a new user on the server
Jump to navigation
Jump to search
## Requirements: - YOU need ROOT access on the server - Let username be the username that the new user is going to have - Let password be the newly set password for this user - Let pub-key be the RSA Public key of the user ## Process: - After SSH-ing into the server, run the command sudo adduser username. Fill out password as the new password, then fill out all the fields, the field Full Name MUST be filled and must contain the REAL name of the user who is being given access. This helps in keeping track of the people who have access to the server. - Run the command sudo -i -u username - Create the .ssh directory: mkdir ~/.ssh - Create the authorized pub keys file: vim ~/.ssh/authorized_keys - Paste pub-key into this file. Do not add any extra whitespaces anywhere. - Change the modes of the new directory and file to make sure that isn't a problem: chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys - Run the commands exit and sudo chage -d 0 username. This will force the user to change their password when they login for the first time. - Send the IP address of the server, SSH Daemon port and their new password to the new user ## Concise process: ```sh sudo adduser username sudo -i -u username mkdir ~/.ssh vim ~/.ssh/authorized_keys # paste the pub key into this file chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys exit sudo chage -d 0 username ```