---
# System prepended metadata

title: Lab 1. System and Network administartion

---

# Lab 1. System and Network administartion
## Mustafin Timur

# Setuping

1. Install latest [docker](https://docs.docker.com/install/) (i used `Docker version 19.03.1, build 74b1e89`), [docker-compose](https://docs.docker.com/compose/install/)(i used `docker-compose version 1.24.1, build 4667896b`). Don't install them just from repos because they may be outdated
2. Clone https://github.com/14MR/sna-labs
3. `cd assignment2` 
4. Create file `authorized_keys` with your public key (or modify the volume if you want)
5. `docker-compose up -d`
6. From your workstation: `ssh -L 31337:app:3000 root@IP_ADDRESS_OF_THE_MACHINE -p 2222`
7. open `http://localhost:31337/` in your browser
![](https://i.imgur.com/W2DmJSv.jpg)


# Images

## SSH 
For ssh i build my own image ([Dockerfile](https://github.com/14MR/sna-labs/blob/master/assignment2/Dockerfile), [Dockerhub](https://hub.docker.com/r/mr14mr/alpine-openssh)). Final version is small enough. I may decrease it more but then i won't benefit from layers.

## Wiki
Just used [Hackmd's open version](https://github.com/hackmdio/CodiMD), [Dockerhub](https://hub.docker.com/r/hackmdio/hackmd)


# Containers and networks

Wiki container has no access to the Internet
```
root@SNA003 assignment2]# docker-compose exec app ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
^C
--- 1.1.1.1 ping statistics ---
111 packets transmitted, 0 packets received, 100% packet loss
```

While SSH has:

```
[root@SNA003 assignment2]# docker-compose exec ssh ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=58 time=63.226 ms
64 bytes from 1.1.1.1: seq=1 ttl=58 time=61.355 ms
64 bytes from 1.1.1.1: seq=2 ttl=58 time=61.041 ms
64 bytes from 1.1.1.1: seq=3 ttl=58 time=61.317 ms
^C
--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 61.041/61.734/63.226 ms
```

Easy to check looking at `docker ps` (PORTS column):
```
[root@SNA003 assignment2]# docker ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                  NAMES
b821f1a5363f        hackmdio/hackmd:1.3.1-alpine   "/usr/local/bin/dock…"   25 minutes ago      Up 25 minutes                              assignment2_app_1
b67bdba9d26b        postgres:11.5-alpine           "docker-entrypoint.s…"   26 minutes ago      Up 25 minutes                              assignment2_database_1
e252de094141        mr14mr/alpine-openssh:latest   "/usr/sbin/sshd -D"      26 minutes ago      Up 26 minutes       0.0.0.0:2222->22/tcp   assignment2_ssh_1
```

# Network diagram

![](https://i.imgur.com/SBMwRVk.png)


