|
| 1 | +Linux Server Configuration |
| 2 | +====================== |
| 3 | +Linux - Apache - Flask - Postgres - Docker Containers |
| 4 | +---------------------------------------------------------------- |
| 5 | +Automated Baseline Linux Server Configuration set up to secure the system from a number of attack vectors, to serve a Postgres database server and an Apache server. |
| 6 | +The Postgres Database Server is configured to run in a **Docker**[^docker] container that uses a docker data volume for easy migrations, backups and restores. |
| 7 | +Th Apache server is dockerized and linked to the Database Server container for a more secure communication style. |
| 8 | + |
| 9 | + |
| 10 | +How to use: |
| 11 | +-------------- |
| 12 | + |
| 13 | +> 1. If not already installed, install openssh by running: |
| 14 | +> >$`sudo apt-get openssh-server` |
| 15 | +
|
| 16 | +> 2. Install git: |
| 17 | +> >$`sudo apt-get install git` |
| 18 | +
|
| 19 | +> 3. Clone the repository into /src: |
| 20 | +>> $ `sudo git clone `[your source] `/src` |
| 21 | +
|
| 22 | +> 4. Login as root and run s1.sh from the "shell" directory |
| 23 | +>>$ `sudo su` |
| 24 | +>>$ `sh /src/shell/s1.sh` |
| 25 | +>>>*here you will be asked to configure unattended-upgrades, timezone, and the password for the new user "grader"* |
| 26 | +
|
| 27 | +> 5. The ssh port is now changed to 2200, exit to your machine, generate an rsa key and upload it to the remote server on port 2200 and user grader: |
| 28 | +> Source: [Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2) |
| 29 | +>> `ssh-keygen -t rsa` *set a file location (usually: /Users/you/.ssh/yourfile) - Mac* |
| 30 | +>> `ssh-copy-id -p 2200 -i /Users/you/.ssh/yourfile grader@ip_addr` |
| 31 | +>> `ssh -p 2200 -i /Users/you/.ssh/yourfile grader@ip_addr` |
| 32 | +
|
| 33 | +> 6. Login as root and run the seccond script |
| 34 | +>>$ `sudo su` |
| 35 | +>>$ `sh /src/shell/s1.sh` |
| 36 | +
|
| 37 | +> 7. DONE! You should now have a working application everything set up. |
| 38 | +
|
| 39 | +User Management |
| 40 | +---------------------- |
| 41 | +Sources: [Askubuntu](http://askubuntu.com/questions/235084/how-do-i-remove-ubuntus-password-requirement), [DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-an-ubuntu-14-04-vps) |
| 42 | +Key points *(done through: /shell/s1.sh lines: 21 -> 47 )*: |
| 43 | + |
| 44 | +> 1. A new user has been created. |
| 45 | +> 2. User "grader" can sudo to root and the password has been set securely. |
| 46 | +> 3. Remote users other then 'grader' have been disabled. |
| 47 | +> 4. "grader" sudo password has been disabled for convenience. |
| 48 | +
|
| 49 | +Security / App Functionality Monitoring - Feedback |
| 50 | +------------------------------------------------------------- |
| 51 | +> 1. Key-based ssh has been enforced. |
| 52 | +> 2. SSH accessible over non-default port 2200. |
| 53 | +> 3. Applications have been updated to the most recent updates. |
| 54 | +> 4. The firewall has been configured to monitor for repeated unsuccessful attempts, appropriately bans attackers and provides automated security feedback. |
| 55 | +> 5. A monitoring software is installed to monitor system availability and status. |
| 56 | +
|
| 57 | +Other Application Functionality |
| 58 | +------------------------------------ |
| 59 | +> 1. Web-server has been dockerized for security and portability; configured to serve the provided application and has been configured to automatically restart in case of critical failure. |
| 60 | +> 2. Database Server has been dockerized for security, portability, has been configured to use a data volume for easy migrations, backups and restores. |
| 61 | +> > **Note: ** *Even though it looks like remote connections have been enabled for the database it is important to notice that the database is not actually accessible remotely from any machine unless it is a purposefully linked docker container. Technically by dockerizing the database server, another layer of security was added.* |
| 62 | +
|
| 63 | + |
| 64 | +Other Security / Functionality Configurations |
| 65 | +----------------------------------------------------- |
| 66 | +> 1. Install ntp for better time synchronization |
| 67 | +> |
| 68 | +
|
| 69 | + |
| 70 | +Short Description of the System |
| 71 | +------------------------------------- |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +Documents |
| 76 | +------------- |
| 77 | + |
| 78 | +StackEdit stores your documents in your browser, which means all your documents are automatically saved locally and are accessible **offline!** |
| 79 | + |
| 80 | +> **Note:** |
| 81 | +
|
| 82 | +> - StackEdit is accessible offline after the application has been loaded for the first time. |
| 83 | +> - Your local documents are not shared between different browsers or computers. |
| 84 | +> - Clearing your browser's data may **delete all your local documents!** Make sure your documents are synchronized with **Google Drive** or **Dropbox** (check out the [<i class="icon-refresh"></i> Synchronization](#synchronization) section). |
| 85 | +
|
| 86 | +#### <i class="icon-file"></i> Create a document |
| 87 | + |
| 88 | +The document panel is accessible using the <i class="icon-folder-open"></i> button in the navigation bar. You can create a new document by clicking <i class="icon-file"></i> **New document** in the document panel. |
| 89 | + |
| 90 | +#### <i class="icon-folder-open"></i> Switch to another document |
| 91 | + |
| 92 | +All your local documents are listed in the document panel. You can switch from one to another by clicking a document in the list or you can toggle documents using <kbd>Ctrl+[</kbd> and <kbd>Ctrl+]</kbd>. |
| 93 | + |
| 94 | +#### <i class="icon-pencil"></i> Rename a document |
| 95 | + |
| 96 | +You can rename the current document by clicking the document title in the navigation bar. |
| 97 | + |
| 98 | +#### <i class="icon-trash"></i> Delete a document |
| 99 | + |
| 100 | +You can delete the current document by clicking <i class="icon-trash"></i> **Delete document** in the document panel. |
| 101 | + |
| 102 | +#### <i class="icon-hdd"></i> Export a document |
| 103 | + |
| 104 | +You can save the current document to a file by clicking <i class="icon-hdd"></i> **Export to disk** from the <i class="icon-provider-stackedit"></i> menu panel. |
| 105 | + |
| 106 | +> **Tip:** Check out the [<i class="icon-upload"></i> Publish a document](#publish-a-document) section for a description of the different output formats. |
| 107 | +
|
| 108 | + |
| 109 | +---------- |
| 110 | + |
| 111 | + |
| 112 | +Synchronization |
| 113 | +------------------- |
| 114 | + |
| 115 | +StackEdit can be combined with <i class="icon-provider-gdrive"></i> **Google Drive** and <i class="icon-provider-dropbox"></i> **Dropbox** to have your documents saved in the *Cloud*. The synchronization mechanism takes care of uploading your modifications or downloading the latest version of your documents. |
| 116 | + |
| 117 | +> **Note:** |
| 118 | +
|
| 119 | +> - Full access to **Google Drive** or **Dropbox** is required to be able to import any document in StackEdit. Permission restrictions can be configured in the settings. |
| 120 | +> - Imported documents are downloaded in your browser and are not transmitted to a server. |
| 121 | +> - If you experience problems saving your documents on Google Drive, check and optionally disable browser extensions, such as Disconnect. |
| 122 | +
|
| 123 | +#### <i class="icon-refresh"></i> Open a document |
| 124 | + |
| 125 | +You can open a document from <i class="icon-provider-gdrive"></i> **Google Drive** or the <i class="icon-provider-dropbox"></i> **Dropbox** by opening the <i class="icon-refresh"></i> **Synchronize** sub-menu and by clicking **Open from...**. Once opened, any modification in your document will be automatically synchronized with the file in your **Google Drive** / **Dropbox** account. |
| 126 | + |
| 127 | +#### <i class="icon-refresh"></i> Save a document |
| 128 | + |
| 129 | +You can save any document by opening the <i class="icon-refresh"></i> **Synchronize** sub-menu and by clicking **Save on...**. Even if your document is already synchronized with **Google Drive** or **Dropbox**, you can export it to a another location. StackEdit can synchronize one document with multiple locations and accounts. |
| 130 | + |
| 131 | +#### <i class="icon-refresh"></i> Synchronize a document |
| 132 | + |
| 133 | +Once your document is linked to a <i class="icon-provider-gdrive"></i> **Google Drive** or a <i class="icon-provider-dropbox"></i> **Dropbox** file, StackEdit will periodically (every 3 minutes) synchronize it by downloading/uploading any modification. A merge will be performed if necessary and conflicts will be detected. |
| 134 | + |
| 135 | +If you just have modified your document and you want to force the synchronization, click the <i class="icon-refresh"></i> button in the navigation bar. |
| 136 | + |
| 137 | +> **Note:** The <i class="icon-refresh"></i> button is disabled when you have no document to synchronize. |
| 138 | +
|
| 139 | +#### <i class="icon-refresh"></i> Manage document synchronization |
| 140 | + |
| 141 | +Since one document can be synchronized with multiple locations, you can list and manage synchronized locations by clicking <i class="icon-refresh"></i> **Manage synchronization** in the <i class="icon-refresh"></i> **Synchronize** sub-menu. This will let you remove synchronization locations that are associated to your document. |
| 142 | + |
| 143 | +> **Note:** If you delete the file from **Google Drive** or from **Dropbox**, the document will no longer be synchronized with that location. |
| 144 | +
|
| 145 | +---------- |
| 146 | + |
| 147 | + |
| 148 | +Publication |
| 149 | +------------- |
| 150 | + |
| 151 | +Once you are happy with your document, you can publish it on different websites directly from StackEdit. As for now, StackEdit can publish on **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **Tumblr**, **WordPress** and on any SSH server. |
| 152 | + |
| 153 | +#### <i class="icon-upload"></i> Publish a document |
| 154 | + |
| 155 | +You can publish your document by opening the <i class="icon-upload"></i> **Publish** sub-menu and by choosing a website. In the dialog box, you can choose the publication format: |
| 156 | + |
| 157 | +- Markdown, to publish the Markdown text on a website that can interpret it (**GitHub** for instance), |
| 158 | +- HTML, to publish the document converted into HTML (on a blog for example), |
| 159 | +- Template, to have a full control of the output. |
| 160 | + |
| 161 | +> **Note:** The default template is a simple webpage wrapping your document in HTML format. You can customize it in the **Advanced** tab of the <i class="icon-cog"></i> **Settings** dialog. |
| 162 | +
|
| 163 | +#### <i class="icon-upload"></i> Update a publication |
| 164 | + |
| 165 | +After publishing, StackEdit will keep your document linked to that publication which makes it easy for you to update it. Once you have modified your document and you want to update your publication, click on the <i class="icon-upload"></i> button in the navigation bar. |
| 166 | + |
| 167 | +> **Note:** The <i class="icon-upload"></i> button is disabled when your document has not been published yet. |
| 168 | +
|
| 169 | +#### <i class="icon-upload"></i> Manage document publication |
| 170 | + |
| 171 | +Since one document can be published on multiple locations, you can list and manage publish locations by clicking <i class="icon-upload"></i> **Manage publication** in the <i class="icon-provider-stackedit"></i> menu panel. This will let you remove publication locations that are associated to your document. |
| 172 | + |
| 173 | +> **Note:** If the file has been removed from the website or the blog, the document will no longer be published on that location. |
| 174 | +
|
| 175 | +---------- |
| 176 | + |
| 177 | + |
| 178 | +Markdown Extra |
| 179 | +-------------------- |
| 180 | + |
| 181 | +StackEdit supports **Markdown Extra**, which extends **Markdown** syntax with some nice features. |
| 182 | + |
| 183 | +> **Tip:** You can disable any **Markdown Extra** feature in the **Extensions** tab of the <i class="icon-cog"></i> **Settings** dialog. |
| 184 | +
|
| 185 | +> **Note:** You can find more information about **Markdown** syntax [here][2] and **Markdown Extra** extension [here][3]. |
| 186 | +
|
| 187 | + |
| 188 | +### Tables |
| 189 | + |
| 190 | +**Markdown Extra** has a special syntax for tables: |
| 191 | + |
| 192 | +Item | Value |
| 193 | +-------- | --- |
| 194 | +Computer | $1600 |
| 195 | +Phone | $12 |
| 196 | +Pipe | $1 |
| 197 | + |
| 198 | +You can specify column alignment with one or two colons: |
| 199 | + |
| 200 | +| Item | Value | Qty | |
| 201 | +| :------- | ----: | :---: | |
| 202 | +| Computer | $1600 | 5 | |
| 203 | +| Phone | $12 | 12 | |
| 204 | +| Pipe | $1 | 234 | |
| 205 | + |
| 206 | + |
| 207 | +### Definition Lists |
| 208 | + |
| 209 | +**Markdown Extra** has a special syntax for definition lists too: |
| 210 | + |
| 211 | +Term 1 |
| 212 | +Term 2 |
| 213 | +: Definition A |
| 214 | +: Definition B |
| 215 | + |
| 216 | +Term 3 |
| 217 | + |
| 218 | +: Definition C |
| 219 | + |
| 220 | +: Definition D |
| 221 | + |
| 222 | + > part of definition D |
| 223 | + |
| 224 | + |
| 225 | +### Fenced code blocks |
| 226 | + |
| 227 | +GitHub's fenced code blocks are also supported with **Highlight.js** syntax highlighting: |
| 228 | + |
| 229 | +``` |
| 230 | +// Foo |
| 231 | +var bar = 0; |
| 232 | +``` |
| 233 | + |
| 234 | +> **Tip:** To use **Prettify** instead of **Highlight.js**, just configure the **Markdown Extra** extension in the <i class="icon-cog"></i> **Settings** dialog. |
| 235 | +
|
| 236 | +> **Note:** You can find more information: |
| 237 | +
|
| 238 | +> - about **Prettify** syntax highlighting [here][5], |
| 239 | +> - about **Highlight.js** syntax highlighting [here][6]. |
| 240 | +
|
| 241 | + |
| 242 | +### Footnotes |
| 243 | + |
| 244 | +You can create footnotes like this[^footnote]. |
| 245 | + [^footnote]: Here is the *text* of the **footnote**. |
| 246 | + |
| 247 | + |
| 248 | +### SmartyPants |
| 249 | + |
| 250 | +SmartyPants converts ASCII punctuation characters into "smart" typographic punctuation HTML entities. For example: |
| 251 | + |
| 252 | +| | ASCII | HTML | |
| 253 | + ----------------- | ---------------------------- | ------------------ |
| 254 | +| Single backticks | `'Isn't this fun?'` | 'Isn't this fun?' | |
| 255 | +| Quotes | `"Isn't this fun?"` | "Isn't this fun?" | |
| 256 | +| Dashes | `-- is en-dash, --- is em-dash` | -- is en-dash, --- is em-dash | |
| 257 | + |
| 258 | + |
| 259 | +### Table of contents |
| 260 | + |
| 261 | +You can insert a table of contents using the marker `[TOC]`: |
| 262 | + |
| 263 | +[TOC] |
| 264 | + |
| 265 | + |
| 266 | +### MathJax |
| 267 | + |
| 268 | +You can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com][1]: |
| 269 | + |
| 270 | +The *Gamma function* satisfying $\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$ is via the Euler integral |
| 271 | + |
| 272 | +$$ |
| 273 | +\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. |
| 274 | +$$ |
| 275 | + |
| 276 | +> **Tip:** To make sure mathematical expressions are rendered properly on your website, include **MathJax** into your template: |
| 277 | +
|
| 278 | +``` |
| 279 | +<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> |
| 280 | +``` |
| 281 | + |
| 282 | +> **Note:** You can find more information about **LaTeX** mathematical expressions [here][4]. |
| 283 | +
|
| 284 | + |
| 285 | +### UML diagrams |
| 286 | + |
| 287 | +You can also render sequence diagrams like this: |
| 288 | + |
| 289 | +```sequence |
| 290 | +Alice->Bob: Hello Bob, how are you? |
| 291 | +Note right of Bob: Bob thinks |
| 292 | +Bob-->Alice: I am good thanks! |
| 293 | +``` |
| 294 | + |
| 295 | +And flow charts like this: |
| 296 | + |
| 297 | +```flow |
| 298 | +st=>start: Start |
| 299 | +e=>end |
| 300 | +op=>operation: My Operation |
| 301 | +cond=>condition: Yes or No? |
| 302 | +
|
| 303 | +st->op->cond |
| 304 | +cond(yes)->e |
| 305 | +cond(no)->op |
| 306 | +``` |
| 307 | + |
| 308 | +> **Note:** You can find more information: |
| 309 | +
|
| 310 | +> - about **Sequence diagrams** syntax [here][7], |
| 311 | +> - about **Flow charts** syntax [here][8]. |
| 312 | +
|
| 313 | +### Support StackEdit |
| 314 | + |
| 315 | +[](https://monetizejs.com/authorize?client_id=ESTHdCYOi18iLhhO&summary=true) |
| 316 | + |
| 317 | + [^docker]: [Docker](https://docker.io) is a fun thing |
| 318 | + [^goo]:goo id fun |
| 319 | + |
| 320 | + [^stackedit]: [StackEdit](https://stackedit.io/) is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites. |
| 321 | + |
| 322 | + |
| 323 | + [1]: http://math.stackexchange.com/ |
| 324 | + [2]: http://daringfireball.net/projects/markdown/syntax "Markdown" |
| 325 | + [3]: https://github.com/jmcmanus/pagedown-extra "Pagedown Extra" |
| 326 | + [4]: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference |
| 327 | + [5]: https://code.google.com/p/google-code-prettify/ |
| 328 | + [6]: http://highlightjs.org/ |
| 329 | + [7]: http://bramp.github.io/js-sequence-diagrams/ |
| 330 | + [8]: http://adrai.github.io/flowchart.js/ |
| 331 | + |
| 332 | + |
| 333 | + |
0 commit comments