Skip to content

Commit 59e94d0

Browse files
committed
chore: Initial commit
0 parents  commit 59e94d0

9 files changed

Lines changed: 307 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write # To push a branch
12+
pages: write # To push to a GitHub Pages site
13+
id-token: write # To update the deployment status
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Install latest mdbook
19+
run: |
20+
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
21+
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
22+
mkdir mdbook
23+
curl -sSL $url | tar -xz --directory=./mdbook
24+
echo `pwd`/mdbook >> $GITHUB_PATH
25+
- name: Build Book
26+
run: |
27+
# This assumes your book is in the root of your repository.
28+
# Just add a `cd` here if you need to change to another directory.
29+
mdbook build
30+
- name: Setup Pages
31+
uses: actions/configure-pages@v4
32+
- name: Upload artifact
33+
uses: actions/upload-pages-artifact@v3
34+
with:
35+
# Upload entire repository
36+
path: "book"
37+
- name: Deploy to GitHub Pages
38+
id: deployment
39+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

book.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[book]
2+
authors = ["mingzezh"]
3+
language = "en"
4+
src = "src"
5+
title = "DAQ Server"

src/.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Remote Access

src/Getting_Started.md

Whitespace-only changes.

src/Remote_Access.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Remote Access
2+
3+
To access the DAQ server remotely we will be using SSH and UCR's VPN. If you
4+
need to use the user with root permission on the server, please ask the DAQ
5+
lead for permissions. All programs that you need are already installed, so to
6+
prevent human errors occurring on the server because of typos or other
7+
misinputs, we have decided to limit the people getting root access on the
8+
server.
9+
10+
## Connect to VPN
11+
12+
<div class="warning">
13+
Please create an UCR engineer account first.
14+
15+
[Follow this guide](https://docs.google.com/document/d/1oX0ZYzlXolmpZ0fJNAy_cVPW6i22R3PRp1TenrxjHMw/edit?usp=sharing).
16+
</div>
17+
18+
You can follow the [UCR's VPN
19+
guide](https://library.ucr.edu/using-the-library/technology-equipment/connect-from-off-campus)
20+
to connect to the BCOE network--which is where our server's LAN is located. If
21+
you don't want to read the UCR guide, we have created a TLDR below that you can
22+
follow. If you are a Linux user or you want an open-source-only option, we have
23+
provided a guide for that below as well.
24+
25+
<details>
26+
<summary>TLDR</summary>
27+
28+
1. Make sure:
29+
* you can login into UCR's CISCO Anyconnect VPN using [vpn.ucr.edu](https://vpn.ucr.edu) (username and password should be the same as how you log into R'web)
30+
* you have an [engineer account](https://docs.google.com/document/d/1oX0ZYzlXolmpZ0fJNAy_cVPW6i22R3PRp1TenrxjHMw/edit?usp=sharing).
31+
2. Log into [vpn.ucr.edu](https://vpn.ucr.edu), and click on continue.
32+
3. You will see instructions telling you how to install CISCO Anyconnect VPN client.
33+
4. Download the client and install it.
34+
5. Open the client and enter `vpn.ucr.edu` as the VPN endpoint where the client will connect to.
35+
6. Click "Connect" and you should be connected to the UCR VPN after a few seconds.
36+
</details>
37+
38+
<details>
39+
<summary>Open source option</summary>
40+
41+
1. First, you need to download the command [`openconnect`](https://www.infradead.org/openconnect/).
42+
* Arch Linux: `sudo pacman -S openconnect`
43+
2. Make sure:
44+
* `curl` is avaliable in your `PATH` environment variable.
45+
* you can login into UCR's CISCO Anyconnect VPN using [vpn.ucr.edu](https://vpn.ucr.edu) (username and password should be the same as how you log into R'web)
46+
* you have an [engineer account](https://docs.google.com/document/d/1oX0ZYzlXolmpZ0fJNAy_cVPW6i22R3PRp1TenrxjHMw/edit?usp=sharing).
47+
3. Download [`vpn.sh`](./vpn.sh) and fill out your `USERNAME` and `PASSWORD` inside of the file on line 3 and 4.
48+
4. `cd` into where `vpn.sh` is located and make it executable `chmod +x vpn.sh`.
49+
5. Run `vpn.sh` with `./vpn.sh`
50+
6. This script will ask for you to approve the login attempt on DUO application everytime you run it.
51+
52+
This is the content of [`vpn.sh`](./vpn.sh):
53+
54+
```sh
55+
#!/bin/env sh
56+
57+
USERNAME=""
58+
PASSWORD=""
59+
DOMAIN="https://vpn.ucr.edu"
60+
61+
#echo -n "Enter DUO Passcode: "
62+
#read DUO_PASSCODE
63+
DUO_PASSCODE="1"
64+
65+
echo Getting the \`tg\` cookie
66+
VAR_tg=$(curl -s -v "${DOMAIN}/+CSCOE+/logon.html?tgroup=FTD_VPN" 2>&1 | grep -i "Set-Cookie:" | grep -oP '(?<=tg=)[^;]+')
67+
68+
echo Getting CSRFtoken cookie
69+
CSRF_TOKEN=$(curl -s "${DOMAIN}/+CSCOE+/logon.html" | grep CSRFtoken | awk -F'"' '{print $4}')
70+
71+
# Random stuff that are required
72+
curl -s "${DOMAIN}/+CSCOE+/logon.html" \
73+
-H "Cookie: tg=${VAR_tg}" \
74+
-H "Referer: ${DOMAIN}/" > /dev/null
75+
76+
curl -s "${DOMAIN}/+CSCOE+/blank.html" \
77+
-H "Cookie: tg=${VAR_tg}; webvpnlogin=1; webvpnLang=en; CSRFtoken=${CSRF_TOKEN}" \
78+
-H "Referer: ${DOMAIN}/+CSCOE+/logon.html" > /dev/null
79+
80+
echo Login using username and password
81+
LOGIN_PAGE=$(curl -X POST -s "${DOMAIN}/+webvpn+/index.html" \
82+
-H "Content-Type: application/x-www-form-urlencoded" \
83+
-H "Cookie: tg=${VAR_tg}; webvpnlogin=1; webvpnLang=en; CSRFtoken=${CSRF_TOKEN}" \
84+
-H "Referer: ${DOMAIN}/+CSCOE+/logon.html" \
85+
--data "tgroup=" \
86+
--data "next=" \
87+
--data "tgcookieset=" \
88+
--data "csrf_token=${CSRF_TOKEN}" \
89+
--data "username=${USERNAME}" \
90+
--data "password=${PASSWORD}" \
91+
--data "Login=Logon")
92+
93+
AUTH_HANDLE=$(echo $LOGIN_PAGE | sed -n 's/.*&auth_handle=\([^"]*\)".*/\1/p')
94+
VAR_a1=$(echo $LOGIN_PAGE | sed -n 's/.*&a1=\([^"]*\)".*/\1/p')
95+
96+
# DUO challenge
97+
HOME_PAGE=$(curl -X POST -v -s "${DOMAIN}/+webvpn+/login/challenge.html" \
98+
-H "Content-Type: application/x-www-form-urlencoded" \
99+
-H "Referer: ${DOMAIN}/+CSCOE+/logon.html?reason=7&a0=2&a1=${VAR_a1}&a2=&a3=0&next=&auth_handle=${AUTH_HANDLE}&status=2&username=${UESRNAME}&serverType=0&challenge_code=0" \
100+
-H "Cookie: tg=${VAR_tg}; webvpnlogin=1; webvpnLang=en; CSRFtoken=${CSRF_TOKEN}" \
101+
-v \
102+
--data "next=" \
103+
--data "auth_handle=${AUTH_HANDLE}" \
104+
--data "status=2" \
105+
--data "username=${USERNAME}" \
106+
--data "challenge_code=0" \
107+
--data "csrf_token=${CSRF_TOKEN}" \
108+
--data "password=${DUO_PASSCODE}" 2>&1)
109+
110+
if [[ "$HOME_PAGE" != *"doStart"* ]]; then
111+
# failed to login
112+
echo failed to login
113+
exit 1
114+
fi
115+
116+
WEBVPN_COOKIE=$(echo $HOME_PAGE | grep "Set-Cookie:" | sed -n 's/.*webvpn=\([^;]*\);.*/\1/p')
117+
118+
echo Sucessfully logged in. Connecting to VPN...
119+
120+
sudo openconnect --protocol=anyconnect -C "webvpn=${WEBVPN_COOKIE}" vpn.ucr.edu
121+
```
122+
123+
The reason why this script is needed is because `sudo openconnect
124+
--protocol=anyconnect vpn.ucr.edu` by itself is not currently compatible with
125+
`vpn.ucr.edu`. What this script does is it extra the login session cookie
126+
from `vpn.ucr.edu` and use it with `openconnect`.
127+
</details>
128+
129+
## SSH Access
130+
131+
For regular members, you should be using the user without root access. We want
132+
to reduce the amount of human errors that can happen on the machine. If you
133+
really need root access, please ask the DAQ lead.
134+
135+
After you are connected to the BCOE network, you can access the server through SSH.
136+
137+
* Server IP: 169.235.18.162
138+
* Username: highlander
139+
* Password: hsp
140+
141+
`ssh highlander@169.235.18.162`

src/SUMMARY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Summary
2+
3+
- [The DAQ Server](./daqserver.md)
4+
- [Getting Started](./Getting_Started.md)
5+
- [Remote Access](./Remote_Access.md)

src/daqserver.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# The DAQ Server
2+
3+
* [Main repo](https://github.com/Highlander-Space-Program/daqserver)
4+
5+
<pre>
6+
@@@@@@@@@@@@
7+
@@@@@@@@ =@@@
8+
@@@@@+ +@@@
9+
@@@@ %@%-@@@@=
10+
@@@ *#@+ =@@@@
11+
@@@@@@% @: +@@@@@
12+
@@@@@@@@@@@@ +*+@@@@@@@@@
13+
%@@@@@@- .@@@@@@@@@@@@: @@@@@@@
14+
%@@@@@ .@@@@@@@@@@ @@@@@@
15+
@@@@@ +@@@ =@+..===:. =@@@@-
16+
@@@@= .: @@= .:.. :.. ... @@@@:
17+
@@@@ . :-= :....... .....::... @@@@
18+
+@@@. .:. .................:.:. @@@@
19+
+@@@ .: .:............... @@@@@ :@@@
20+
+@@@ .: :::................. =@@@@# %@ :@@@ .::
21+
@@@ . :::..............:- .=. *@@@ @@@@@@@@@@@@@@@@@@@@
22+
#@@@ .: :.:................: :*@@@@:@@@@@@ @@@@@ .@==*--@@@
23+
@@* :::.............. . @ :%@@@@@@@@: @@@@ @@* @@@@
24+
%@@= .. --...:-:...................:... @@@@ @@ @@@@ *@= @@@@@@
25+
.@@* .: =+ .--:.:.............:....:::.. .@@@@@: @@ @@ @@@ =@@@
26+
@@@ .::::.....................:-=---: @@@@+.-#@% +@+ @@=@@ @
27+
@@@ ..:.:..................:... @@@ @@@@ @@ @@
28+
@@@ ..::::::....:::... :::. -@@@ @@ @ @@@ .@@
29+
@@@ ..............:. @@@@@@@@ @@#*@@@@@@ @@- @@%
30+
@@@ ................:. @@@@@-@@@@ @@@ -@@ @@@ %@@
31+
@@@ ..:......:::.... .@@@%: @@ @* @@@@+ .@@
32+
@@@ .......... : @@@@@@@@@@@@ @@ @@@@@ @@@@ @@@
33+
@@@ :........:--:.#@@@#.. +@@. @@@@@@ @@@ @@@@@:
34+
@@@@+ ......... .:-- +@@@@@@ @ *@@ -@@@*@@@
35+
@ @@@ -:::. =@@@@@@@@ @@@ .. @@@@ #@@.
36+
@@ @@@ ....... . #@@@@@@@@@@@+ @@ *@@@@@ *@@@
37+
@@ @@@@ .--. -@@@@@@@@@@@@@@@@ =@@@@@@: : -#@@@
38+
@@@ @@@= @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -+-= @@@@
39+
@@@ @@@%. . +@@@@# -:.*@@@@@@@@@@@%@@@@@@@@@@ -%#*+: -@@@@
40+
@@@@ @@@@@@@@@+-:-:+*#@@@@@@@* %@@@@@@@: --== %@@@
41+
@@@+ =@%*=*=-=====--@@@@. -@@@@@@@+ +###+. @@@@@
42+
@@+@@ .@@@@@@=-+++--:..-@@@@* .=-=+-+@@@@@@@ -+*= @@@@@
43+
@@=+@@@@@@@@%=--+**+:-%@@@@@@* =+*#*+@@@@@ .-=- .*@@@@%
44+
@@+==--.:+##*===+@@@@@@= +@@@@@= . -:. -@@@@@@
45+
#@@@@%#%@##@@@@@@@@ *@@@@@@@@% #@@@@@@@@
46+
@@@@@@@@@- .@@@@@@@@@@@@@@@@@@@@@@@
47+
</pre>
48+

src/vpn.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/env sh
2+
3+
USERNAME=""
4+
PASSWORD=""
5+
DOMAIN="https://vpn.ucr.edu"
6+
7+
#echo -n "Enter DUO Passcode: "
8+
#read DUO_PASSCODE
9+
DUO_PASSCODE="1"
10+
11+
echo Getting the \`tg\` cookie
12+
VAR_tg=$(curl -s -v "${DOMAIN}/+CSCOE+/logon.html?tgroup=FTD_VPN" 2>&1 | grep -i "Set-Cookie:" | grep -oP '(?<=tg=)[^;]+')
13+
14+
echo Getting CSRFtoken cookie
15+
CSRF_TOKEN=$(curl -s "${DOMAIN}/+CSCOE+/logon.html" | grep CSRFtoken | awk -F'"' '{print $4}')
16+
17+
# Random stuff that are required
18+
curl -s "${DOMAIN}/+CSCOE+/logon.html" \
19+
-H "Cookie: tg=${VAR_tg}" \
20+
-H "Referer: ${DOMAIN}/" > /dev/null
21+
22+
curl -s "${DOMAIN}/+CSCOE+/blank.html" \
23+
-H "Cookie: tg=${VAR_tg}; webvpnlogin=1; webvpnLang=en; CSRFtoken=${CSRF_TOKEN}" \
24+
-H "Referer: ${DOMAIN}/+CSCOE+/logon.html" > /dev/null
25+
26+
echo Login using username and password
27+
LOGIN_PAGE=$(curl -X POST -s "${DOMAIN}/+webvpn+/index.html" \
28+
-H "Content-Type: application/x-www-form-urlencoded" \
29+
-H "Cookie: tg=${VAR_tg}; webvpnlogin=1; webvpnLang=en; CSRFtoken=${CSRF_TOKEN}" \
30+
-H "Referer: ${DOMAIN}/+CSCOE+/logon.html" \
31+
--data "tgroup=" \
32+
--data "next=" \
33+
--data "tgcookieset=" \
34+
--data "csrf_token=${CSRF_TOKEN}" \
35+
--data "username=${USERNAME}" \
36+
--data "password=${PASSWORD}" \
37+
--data "Login=Logon")
38+
39+
AUTH_HANDLE=$(echo $LOGIN_PAGE | sed -n 's/.*&auth_handle=\([^"]*\)".*/\1/p')
40+
VAR_a1=$(echo $LOGIN_PAGE | sed -n 's/.*&a1=\([^"]*\)".*/\1/p')
41+
42+
# DUO challenge
43+
HOME_PAGE=$(curl -X POST -v -s "${DOMAIN}/+webvpn+/login/challenge.html" \
44+
-H "Content-Type: application/x-www-form-urlencoded" \
45+
-H "Referer: ${DOMAIN}/+CSCOE+/logon.html?reason=7&a0=2&a1=${VAR_a1}&a2=&a3=0&next=&auth_handle=${AUTH_HANDLE}&status=2&username=${UESRNAME}&serverType=0&challenge_code=0" \
46+
-H "Cookie: tg=${VAR_tg}; webvpnlogin=1; webvpnLang=en; CSRFtoken=${CSRF_TOKEN}" \
47+
-v \
48+
--data "next=" \
49+
--data "auth_handle=${AUTH_HANDLE}" \
50+
--data "status=2" \
51+
--data "username=${USERNAME}" \
52+
--data "challenge_code=0" \
53+
--data "csrf_token=${CSRF_TOKEN}" \
54+
--data "password=${DUO_PASSCODE}" 2>&1)
55+
56+
if [[ "$HOME_PAGE" != *"doStart"* ]]; then
57+
# failed to login
58+
echo failed to login
59+
exit 1
60+
fi
61+
62+
WEBVPN_COOKIE=$(echo $HOME_PAGE | grep "Set-Cookie:" | sed -n 's/.*webvpn=\([^;]*\);.*/\1/p')
63+
64+
echo Sucessfully logged in. Connecting to VPN...
65+
66+
sudo openconnect --protocol=anyconnect -C "webvpn=${WEBVPN_COOKIE}" vpn.ucr.edu
67+

0 commit comments

Comments
 (0)