Skip to content

Lab PC User Account Setup

Pavlo Mospan edited this page Jan 12, 2022 · 5 revisions

Create User Account

Log into the main account with sudo permissions. Then issue following command to create a new user account. It will prompt you several settings like display username, password, etc.

sudo adduser <username>

The interactive prompts will look something like this:

sudo adduser troestma
Adding user `troestma' ...
Adding new group `troestma' (1002) ...
Adding new user `troestma' (1002) with group `troestma' ...
Creating home directory `/home/troestma' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for troestma
Enter the new value, or press ENTER for the default
	Full Name []: Marco Tröster
	Room Number []: 
	Work Phone []: 
	Home Phone []: 
	Other []: 
chfn: name with non-ASCII characters: 'Marco Tröster'
Is the information correct? [Y/n] y

Assign User Account to Groups

Now you've got a blank user account. The problem with this is that you won't be able to install programs or access some hardware or launch Docker containers, etc. Therefore you'll need to assign you to following groups with the given command.

sudo usermod -aG <group> <username>

Groups to assign:

  • adm
  • cdrom
  • sudo
  • dip
  • plugdev
  • lpadmin
  • lxd
  • sambashare
  • docker
sudo usermod -aG adm <username>
sudo usermod -aG cdrom <username>
sudo usermod -aG sudo <username>
sudo usermod -aG dip <username>
sudo usermod -aG plugdev <username>
sudo usermod -aG lpadmin <username>
sudo usermod -aG lxd <username>
sudo usermod -aG sambashare <username>
sudo usermod -aG docker <username>

Note: You need a reboot to make the changes apply.

sudo reboot

Validate User Group Assignment

After a reboot, you can log into the account you've just created. For a quick verification of settings, execute following command. It will list the groups your user account is assigned to.

id

An example output looks something like this:

uid=<userid>(<username>) gid=<userid>(<username>) groups=<userid>(<username>),4(adm),
24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),132(lxd),133(sambashare),136(docker)

GitHub SSH Key Generation

Next, we need to set up a SSH key to securely communicate with the GitHub servers. GitHub more and more enforces a higher security policy, forbidding just plain username + password sign-ins and requiring a 2FA. Using a SSH key simplifies this a lot because you only have to enter you passphrase once you connect to GitHub after each user account login.

ssh-keygen -t ed25519 -C <email-address>

The interaction with the command prompt might look like this:

Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/<username>/.ssh/id_ed25519): 
Enter passphrase (empty for no passphrase): ************
Enter same passphrase again: ************
Your identification has been saved in /home/<username>/.ssh/id_ed25519
Your public key has been saved in /home/<username>/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:6DVibu/kOsHhNtCS3t82JUuCC7ouu3MtitImaOLRANg <email-address>
The key's randomart image is:
+--[ED25519 256]--+
|                 |
|..               |
|o E  o           |
|.   + o.         |
| . . *+oS        |
|  o o+Oo..o .    |
|.o + o+=.+ +     |
|O.B ..o+. =      |
|X%oo  .++. .     |
+----[SHA256]-----+

GitHub SSH Key Registration

Now, you need to register your public SSH key on GitHub. Print you key to the console and copy it.

cat ~/.ssh/id_ed25519.pub

Then log into GitHub and navigate to the user account settings: User Account -> Settings -> SSH and GPG Keys -> New SSH Key. Insert the copied SSH key there. The SSH connection should work now.

GitHub Repository Clone + Setup

Finally you can clone you own copy of the Git repository and set it up for meeting your needs. Therefore clone the repo, and register your username and email which gets appended to your git commits to identify the authorship of your commits.

git clone ssh://git@github.com/ll7/paf21-1
cd paf21-1
git config --local user.name <full username>
git config --local user.email <email>

Since there are some large files in the repo, they were push with Git Large File Storage, we must need to setup one:

  1. use the link above to download directory
  2. Go into the directory and install install.sh file (sudo ./install.sh on Linux)
  3. In that directory use git lfs install
  4. Pull everything from repo again git lfs pull

After all the configuration is done, you can test you git setup by executing this command:

git remote update