# CLAMV and Shell Quickstart
> (∩`-´)⊃━☆゚.*・。゚
In this short introduction I gathered essential things you should know to handle CLAMV well. This includes
1. `ssh` or "How do I connect to CLAMV?"
2. Looking around or `pwd`, `mkdir` and `ls`
3. Uploading files with `scp`
4. Managing permissions or "Why does not Apache see the files?"
5. Keeping your directory in sync using `git`
#### Requirements
Any shell such as PowerShell, sh, bash or zsh (hello to the Macintosh folk). Microsoft's cmd.exe lacks features. I recommend replacing it with PowerShell.
You should be inside the university's network. I recommend using a VPN. `eduroam` might not be enough. [Setup your AnyConnect VPN software here](https://teamwork.constructor.university/pages/viewpage.action?pageId=215616420).
## 1. `ssh` or "How do I connect to CLAMV?"
CLAMV is a remote server that runs Linux. To connect, use this command replacing the name with yours
`ssh sbell@clabsql.clamv.jacobs-university.de`
No credentials? Let the TA team know. Just make sure that you have not missed any emails from `agelessus@constructor.university` first.
#### 1.1 (Not required) Connecting via an SSH key
You may want to simplify the connection process in future by generating an ssh key with the following steps.
<details>
<summary>Click me!</summary>
1. Generate a public-private key pair
`ssh-keygen -t ecdsa`
> Output
> `Your identification has been saved in ~/.ssh/id_ecdsa`
2. `cat ~/.ssh/id_keyname.pub`
> Output. Copy it and use in the following steps
> `ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCmhvF5U11B5e9CLV7JWoVqiLjSbR3PiqEJ7l+68erbSYezVg2TQ9rzmSics9otBLT+QqksGPUhkqOZPjZAIf+g=`
3. Now connect to CLAMV using your username and password
`ssh sbell@clabsql.clamv.jacobs-university.de`
4. Append your key to a special file called `authorized_keys`
`sbell@clabsql:~> echo "{insert your key here}" > ~/.ssh/authorized_keys`
5. `sbell@clabsql:~> cat ~/.ssh/authorized_keys`
This command should output your key. Use it as a sanity check
**Profit!**
Now you are able to avoid using your password all the time by employing your private key. Like this
`ssh sbell@clabsql.clamv.jacobs-university.de -i ~/.ssh/id_keyname`
> Output
> Last login: Sun Sep 24 19:46:40 2023 from 10.222.128.211
> Have a lot of fun...
</details>
## 2. Looking Around
Whenever you are connected to CLAMV, you happen to be inside a shell. Shell is an environment where you can execute commands.
Each command is aware of the place where it runs – this place is called "working directory".`pwd` mnemonic stands for "print working directory" and this is exactly what it does. Let's try!
`sbell@clabsql:~> pwd`
> Output
> `/home/sbell`
`ls` command lists files in the current directory. Now it's empty. Let us first create something.
`sbell@clabsql:~> mkdir public_html`
`sbell@clabsql:~> ls`
> Output
> `public_html`
## 3. Uploading Files with `scp`
To initialize the web page directory, you will need to upload files. A common way to do this is with `scp`. It stands for "secure copy".
Run this on your machine locally. Note that the command starts after the `%` sign.
```
sbell@local dbws % scp index.html sbell@clabsql.clamv.jacobs-university.de:public_html/index.html
Output
index.html 100% 7 1.4KB/s 00:00
```
You are still not able to see the file through the public link tho. To be continued in the following section.
## 4. Managing Permissions
Apache server runs at the machine you are connecting to. You are in complete control of the files that the Apache server can serve.
In a Unix-compatible system which is our exactly our case, each file has three permission bits – r, w and x.
r is for read
w is for write
x is for execute
The "execute" bit might convey different things depending on the context. When it is applied to a directory (i.e. `public_html`), it signifies the ability to list the content of it. For example, with `ls public_html`.
Run this to help Apache find your index file. `o+x` says "allow access to files in the directory to everybody".
`sbell@clabsql:~> chmod -R o+xr ~`
Note: files inside are now available to literally everyone, this is a security concern.
Replace with your name.
http://clabsql.clamv.jacobs-university.de/~mliamets/

Still does not work? Contact the author.
## 5. Keeping Web Directory in Sync
Be careful. The following commands overwrite the destination.
1. Use `rsync`. This will copy files from ./public_html to the remote.
`-a` to preserver file permissions (i.e. read, write and execute bits)
`-v` to make the output verbose
`-z` to compress
`rsync ./public_html -avz sbell@clabsql.clamv.jacobs-university.de:`
2. Use `scp`. This will do the same but take longer.
`scp` preserves file permissions by default.
`scp -r ./public_html sbell@clabsql.clamv.jacobs-university.de:`
#### Sources (งツ)ว
[Linux Shell Tutorial](https://linuxcommand.org/). "Looking around" page is enough to start off
[Peter Baumann's "How to Setup My Own Web Pages Directory"](https://peter-baumann.org/Courses/Databases+WebServices/howto-setup-html.php)

###### Author aka "This could have been better" – [Mikhail Liamets \<mliamets@constructor.university\>](mailto:mliamets@constructor.university)