Assignment 01
- Due to March 19,2023 - 08.15
Important commands of the lecture
ssh meise@meise.cosy.sbg.ac.at # ssh remote login
sudo useradd -m username # add user and make home directory - use superuser right sudo = super user do
sudo passwd username # change password of new user
usermod -aG sudo username # add user to superuser group
exit # logout
ssh username@meise.cosy.sbg.ac.at # login with the new user
pwd # show current working directory = /home/username/
cssh # change shell to /bin/bash
exit
ssh username@meise.cosy.sbg.ac.at # login to get bash
sudo apt install nginx # install nginx
cd /var/www/html/ # change to the directory with the initial html file of nginx
ls # show content
sudo nano index.nginx-debian.html # open file in nano -> edit, save STRG+O, exit STRG+C
sudo ufw status # check ufw
sudo ufw allow 22 # enable ssh
sudo ufw allow 80 # enable http on port 80
sudo ufw allow 443 # enable https on port 443
sudo ufw enable # activate firewall
sudo ufw status # check status
Already done in the lecture
- Create user accounts for all group members on your VM. Think of who is getting sudo rights (all, admin only?) ✅
- Install nginx as webserver on the VM. ✅
Todo
- Group task - Config nginx
- Configure nginx ( Location/root configuration) to route to the user pages - login in to remote and:
config block for each user
location /username {
rewrite ^([^.]*[^/])$ $1/ permanent;
alias /home/username/public_html;
index index.html;
}
cd /etc/nginx/sites-available
sudo nano default
# For each user you must copy and modify the config block in the server block of default
# start below the location block which is already in the configuration
# save and exit
sudo systemctl reload nginx # restart webserver
2. Each user: Read the slides dealing with SSH and configure ssh access using public/private key.
- Each user: Prepare a personal page in your home directory.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Assignment_01</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<h1>Assignment_01 - Welcome</h1>
<h2>Add a link to the landing page of your meise</h2>
<p>
<!-- TODO(you): Add a link here -->
</p>
<h2>What is your name?</h2>
<p>
<!-- TODO(you): Enter your answer here -->
</p>
<h2>What is a fun fact about yourself?</h2>
<p>
<!-- TODO(you): Enter your answer here -->
</p>
<h2>What do you look like?</h2>
<!-- TODO(you): Add a picture of yourself or of something that represents yourself. -->
</body>
</html>
style.css
body {
font-family: monospace;
}
Login to your meise and:
pwd # Check the if you are in your home directory /home/username
ls # show files in your home director - should be empty at the moment
mkdir public_html # create directory for your personal site
nano index.html # copy content of index.html into nano and modify content, save and exit
# ! For the image part a note will follow at the end
nano style.css # copy content of style.css into nano, save and exit
For including an image in index.html
read W3Schools Image. You need to upload an image to your public_html
. You can do this via command line (e.g. scp) or you use an FTP client (Putty or Filezilla) to copy the file from your local machine to the remote machine. Find out how to acomplish this task.
- Each user - Fix Permissions:
Login to remote and:
cd ..
chmod 711 username # add right to others to enter your home directory
cd username
chomd 711 public_html # add right to others to enter your public_html directory
chmod 644 public_html/* # add right to others to read your files
Check if you can access your page: http://vogel.cosy.sbg.ac.at/username/
Permissions
- Please read File Permissions
- Fix the directory and file permissions as follows, in case you have no permission to view your files in public_html
/home/youruserdirectory/
- set directory permission to 711
chmod 711 /home/youruserdirectory/
/home/youruserdiretory/public_html/
- set permissions of directory and all content to 755
chmod -R 755 /home/youruserdirectory/public_html/
-
Group task:
-
Create a landing page for
http://vogel.cosy.sbg.ac.at/
. This requires to further modify the index file in/var/www/html
as we did in the lecture. You can modify the file via terminal (as in the lecture) or you download it (Filezilla, Putty, ..), modify it and upload it to the server again. - Show at least the name of your host and list the group members. Keep it simple! (NO CSS required at the moment).
Provide a link to the page of each userhttp://vogel.cosy.sbg.ac.at/username/
.