diff options
Diffstat (limited to 'content')
| -rw-r--r-- | content/basic/domain.md | 8 | ||||
| -rw-r--r-- | content/dendrite.md | 6 | ||||
| -rw-r--r-- | content/ejabberd.md | 5 | ||||
| -rw-r--r-- | content/git.md | 2 | ||||
| -rw-r--r-- | content/i2p.md | 82 | ||||
| -rw-r--r-- | content/jitsi.md | 2 | ||||
| -rw-r--r-- | content/monerod.md | 228 | ||||
| -rw-r--r-- | content/mumble.md | 134 | ||||
| -rw-r--r-- | content/prosody.md | 52 | ||||
| -rw-r--r-- | content/radicale.md | 6 | ||||
| -rw-r--r-- | content/transmission.md | 844 | ||||
| -rw-r--r-- | content/wireguard.md | 15 |
12 files changed, 1326 insertions, 58 deletions
diff --git a/content/basic/domain.md b/content/basic/domain.md index b0fdeff..a6b762b 100644 --- a/content/basic/domain.md +++ b/content/basic/domain.md @@ -32,25 +32,25 @@ Domains can be registered at any accredited <dfn>registrar</dfn> and there are [Name Cheap](https://www.namecheap.com/domains/) or [Dream Host](https://www.dreamhost.com/domains/). -There are also sites that are more private like [Njalla](https://njal.la/) and +There are also sites that are more private, like [Njalla](https://njal.la/) and [Cheap Privacy](https://cheapprivacy.ru/), which register a domain for you under their name, but still allow you access to it. (Normally all websites must be registered with the ICANN with a real name and address, but these sites allow you to bypass that.) Choosing a registrar is not permanent, and you can transfer domains to a -different registrar if get a better deal later, so in most cases, you can just +different registrar if you get a better deal later, so in most cases, you can just choose one and let's head on... ### Basic info about domain names -- Domain names usually require a *very* small year fee to keep +- Domain names usually require a *very* small yearly fee to keep registered, usually around \$12 for most generic TLDs. There are some \"specialty\" TLDs that are more expensive, but `.com`, `.xyz` and other basic TLDs are that cheap. - Once you own a domain, it is yours as long as you pay the yearly fee, but you can also sell it to someone for however much you want. -- Domain names do not hold your data or your website, instead, you add +- Domain names do not hold your data or your website; instead, you add \"DNS settings\" that direct people connecting to your domain to your IP address. The purpose of a domain name is so that people don\'t have to remember your IP address to find your website! diff --git a/content/dendrite.md b/content/dendrite.md index 79d2417..9a7a291 100644 --- a/content/dendrite.md +++ b/content/dendrite.md @@ -118,10 +118,10 @@ Now download the Dendrite repository using `git` and change directory to it: git clone https://github.com/matrix-org/dendrite cd dendrite ``` -Finally, run the `./build.sh` script to compile Dendrite: +Finally, compile Dendrite using `go build`: ```sh -./build.sh +go build -o bin/ ./cmd/... ``` *This might take a few minutes,* but once the process is finished you should find the final Dendrite programs populating the `bin/` directory. @@ -231,7 +231,7 @@ chown -R dendrite:dendrite /opt/dendrite ### Setting up a systemd Service -Now setup a **systemd service** to run Dendrite automatically for you. Make sure to set the `WorkingDirectory` to the directory where your Dendrite repository is located! +Now setup a **systemd service** in `/etc/systemd/system/dendrite.service` to run Dendrite automatically for you. Make sure to set the `WorkingDirectory` to the directory where your Dendrite repository is located! ```systemd [Unit] diff --git a/content/ejabberd.md b/content/ejabberd.md index c725465..eff3b36 100644 --- a/content/ejabberd.md +++ b/content/ejabberd.md @@ -191,6 +191,11 @@ PostgreSQL is available in the Debian repositories: apt install postgresql ``` +In addition, you will have to install the **appropriate headers for Erlang,** the language ejabberd is written in, so it can actually interact with the PostgreSQL server: +```sh +apt install erlang-p1-pgsql +``` + Start the PostgreSQL daemon to begin using it: ```sh diff --git a/content/git.md b/content/git.md index f11d79d..7cb0121 100644 --- a/content/git.md +++ b/content/git.md @@ -100,7 +100,7 @@ chown git:git -R /var/git/.ssh # Make the created directory and contents to be o ### Syncing a new repository with your server -How that we've set that up, we can push a repository we have on our computer to +Now that we've set that up, we can push a repository we have on our computer to that newly created bare repo. First, on our local computer, we run a command like this: ```sh diff --git a/content/i2p.md b/content/i2p.md index d0b2edb..88b05b4 100644 --- a/content/i2p.md +++ b/content/i2p.md @@ -7,13 +7,11 @@ tags: ['service'] short_desc: "A private and uncensorable web-layer similar to Tor." --- -Now you have a website, why not offer it in a private alternative such -as the Invisible Internet? +Now you have a website, why not offer it in a private alternative such as the Invisible Internet? ## Setting up I2P -There are 2 main I2P implementations, I2P and i2pd, we are using i2pd in -this guide because it\'s easier to use in servers. +There are 2 main I2P implementations, I2P and i2pd, we are using i2pd in this guide because it\'s easier to use in servers. ### Installing I2P @@ -25,9 +23,7 @@ apt install i2pd ### Enabling I2P -We are going to create a user for i2pd, because i2pd finds the -configuration files in its home directory. And it\'s easier (and more -tidy) to have it in a separate user: +We are going to create a user for i2pd, because i2pd finds the configuration files in its home directory. And it\'s easier (and more tidy) to have it in a separate user: ```sh useradd -m i2p -s /bin/bash @@ -36,9 +32,7 @@ mkdir ~/.i2pd cd ~/.i2pd ``` -Now that you\'re in \~/.i2pd, you have to create a file named -\"tunnels.conf\". Which is the config file for every hidden service -you\'re offering over I2P, the content should be like this: +Now that you\'re in \~/.i2pd, you have to create a file named \"tunnels.conf\". Which is the config file for every hidden service you\'re offering over I2P, the content should be like this: ```systemd [example] @@ -48,13 +42,58 @@ port = 8080 keys = example.dat ``` +#### Optional: Generating a Vanity Address + +If you run `i2pd` with the configuration above, it will generate a random private key (`example.dat`) for your website in `example.dat` with a matching address made up of 52 random characters, derived from this same key. + +If you instead pre-generate a private key for your website, you can use brute-force computation to make a "vanity" address, such as the following: +``` +{{<hl>}}chad{{</hl>}}aor3jc08ht340c30mg5cf340j395gj095kuazj5tokipr34f.32.i2p +``` + +To accomplish this, a set of tools named `i2pd-tools` can be installed. + +Begin by cloning their repository: +```sh +git clone --recursive https://github.com/purplei2p/i2pd-tools +``` + +The repository comes with a dependency installation script included. Run this to list the compilation dependencies you'll need, and install them: +```sh +cd i2pd-tools +sh dependencies.sh +``` + +Then compile using the `make` command: +```sh +make -j$(nproc) +``` + +This will build a variety of useful tools for i2p, with `vain` being the command of interest to generate an address: +```sh +./vain {{<hl>}}chad{{</hl>}} +``` +This command will begin running and output a new set of private keys named `private.dat` to the same directory it's ran from. Copy this file to your i2p configuration and you'll have your vanity address: + +```sh +cp private.dat /home/i2p/.i2pd/example.dat +``` + +#### Optional: Authentication Strings for Registrars + +I2P has various **registrars** that let users link their long I2P addresses to shorter, more memorable ones, like `example.i2p`. To actually register your site on one of these registrars, you will need an **authentication string.** Luckily, `i2pd-tools` includes such a tool in their repository: + +```sh +./regaddr private.dat {{<hl>}}example.2ip{{</hl>}} > {{<hl>}}auth_string.txt{{</hl>}} +``` + +The command above will save the string to a file named `auth_string.txt`. You will have to place the text contained in that file on a registration page like [http://reg.i2p/add](http://reg.i2p/add) or [http://stats.i2p/i2p/addkey.html](http://stats.i2p/i2p/addkey.html). + ### Getting your I2P Hostname -Then, run `/usr/sbin/i2pd --daemon` to start i2pd and we can retreive -our I2P hostname. +Then, run `/usr/sbin/i2pd --daemon` to start i2pd and we can retreive our I2P hostname. -This can be done in lynx or a command-line browser by going to -`http://127.0.0.1:7070/?page=i2p_tunnels` to get your I2P hostname. +This can be done in lynx or a command-line browser by going to `http://127.0.0.1:7070/?page=i2p_tunnels` to get your I2P hostname. You can also run these commands to find your hostname: @@ -63,12 +102,11 @@ printf "%s.b32.i2p " $(head -c 391 /home/i2p/.i2pd/example.dat |sha256sum|xxd -r -p | base32 |sed s/=//g | tr A-Z a-z) ``` +*(If you've generated your own keys to obtain a vanity address, now's a good time to make sure i2pd is properly reading those keys by verifying the address is the same as the one generated with the `vain` command.)* + ## Adding the Nginx Config -From here, the steps are almost identical to setting up a normal website -configuration file. Follow the steps as if you were making a new website -on the webserver [tutorial](/basic/nginx) up until the server block of -code. Instead, paste this: +From here, the steps are almost identical to setting up a normal websitenconfiguration file. Follow the steps as if you were making a new website on the webserver [tutorial](/basic/nginx) up until the server block of code. Instead, paste this: ```nginx server { @@ -82,13 +120,9 @@ server { #### -Nginx will listen in port 8080, but i2pd will forward your port 8080 to -the i2p site port 80. This way you don\'t have to deal with server names -or anything like that +Nginx will listen in port 8080, but i2pd will forward your port 8080 to the i2p site port 80. This way you don\'t have to deal with server names or anything like that. -From here we are almost done, all we have to do is enable the site and -reload nginx which is also covered in [the webserver -tutorial](nginx.html#enable). +From here we are almost done, all we have to do is enable the site and reload nginx which is also covered in [the webserver tutorial](nginx.html#enable). ### Update regularly! diff --git a/content/jitsi.md b/content/jitsi.md index 82246dd..0df893b 100644 --- a/content/jitsi.md +++ b/content/jitsi.md @@ -175,7 +175,7 @@ You now need to register some users in [Prosody](/prosody), you can do so manually using `prosodyctl`: ```sh -prosodyctl register <username> meet.example.org <password> +prosodyctl register <username> meet.example.org <password> ``` Finally, restart `prosody`, `jicofo`, and `jitsi-videobridge2`: diff --git a/content/monerod.md b/content/monerod.md new file mode 100644 index 0000000..5e00645 --- /dev/null +++ b/content/monerod.md @@ -0,0 +1,228 @@ +--- +title: "Monero Node" +icon: 'xmr.svg' +date: '2021-06-29' +tags: ['service'] +short_desc: "Contribute to the Monero network." +--- + +The Monero cryptocurrency relies on a network of [decentralized nodes](https://www.getmonero.org/resources/moneropedia/node.html) to store the private transaction information and maintain consensus. + +Running your own node will let you relay transactions and contribute to the Monero network by dedicating storage and processing power to the task. You can then connect to your node from a wallet (if you enable rps). + +Some other benefits of a full node are: + +- More reliable and trusted as opposed to using a public node +- More secure for RPC calls for payment processors +- The ability to mine using [p2pool](https://p2pool.io/#help) +- The ability to run a mining pool or solo mine\* + +**Note: Solo mining can be very unreliable and it is not recommended unless you have a very powerful computer.* + +**Warning:** Running a Monero node requires *a lot of storage* (at least 100GB) and a reasonable amount of memory and processing power. If you are hosting at home, make sure to use an **SSD** and not a hard disk drive, as advised by `monerod`. + +## Installation + +Because of the nature of Monero as an ever-evolving decentralized project, it is advised to download and keep an up-to-date version of it for your node. This can be accomplished by downloading the software manually: + +```sh +wget https://downloads.getmonero.org/linux64 +tar -xvjf linux64 +mv linux64/monero* /usr/bin/ +``` + +## Configuration + +By default, Monero comes with no sample configuration files. Create one in `/etc/monerod.conf` using a text editor, and enter the following details: + +```sh +# Configuration for monerod +# Syntax: any command line option may be specified as 'clioptionname=value'. +# Boolean options such as 'no-igd' are specified as 'no-igd=1'. +# See 'monerod --help' for all available options. + +data-dir={{<hl>}}/var/lib/monero{{</hl>}} +log-file={{<hl>}}/var/log/monero/monero.log{{</hl>}} +log-level=0 + +# 1048576 kB/s == 1GB/s; a raise from default 2048 kB/s; contribute more to p2p network +limit-rate-up=1048576 +limit-rate-down=1048576 + +# Be more generous to wallets connecting +disable-rpc-ban=1 +``` + +### Log files + +The logfile at `/var/log/monero/monerod.log` will get **very large, very soon** if you do not limit it's size. Add these options to `/etc/monerod.conf` to limit it's size, and limit the creation of additional log + backups: + +```sh +# Limit log size to 10 MiB +max-log-file-size=10485760 +max-log-files=5 +``` + +### Making a Public Node + +To advertise and let other users connect to your node, enable the following options: + +```sh +restricted-rpc=true +# Bind to all addresses (useful if under NAT) +p2p-bind-ip=0.0.0.0 +rpc-bind-ip=0.0.0.0 +confirm-external-bind=1 + +public-node=true +``` + +### User creation + +Create a dedicated user to run `monerod` named `monero`: +```sh +useradd -m -d /var/lib/monero monero +``` + +Create the directories, and ensure the user has the relevant permissions on them: +```sh +mkdir /var/lib/monero && chown -R monero:monero /var/lib/monero +mkdir /var/log/monero && chown -R monero:monero /var/log/monero +``` + +### Pruning the blockchain + +When running a node, [pruning](https://www.getmonero.org/resources/moneropedia/pruning.html) allows the user to save data by only storing 1/8th of the ring signature information. Every "pruned" node contains a random 1/8th of the data, so the information is never lost. While this isn't as helpful to the network as running a full node, it is a very reasonable option when storage space and bandwidth are limited. **A pruned node will only use 1/3rd of storage compared to a full node.** + +To enable pruning, add the following options to `/etc/monerod.conf`: +```sh +prune-blockchain=true +# This option should speed up the syncing process +sync-pruned-blocks=true +``` + +## Tor/I2P Setup + +from the Monero documentation: + +> Only handshakes, peer timed syncs and transaction broadcast messages are supported over anonymity networks. + +Monero nodes **cannot sync the blockchain over Tor or I2P,** but the node can broadcast transactions and *let users connect* over these anonymizing networks. + +To set this up, first install [Tor](/tor) and/or [I2P](/i2p). + +When creating a hidden service, create the following configuration: + +### Tor + +Edit `/etc/tor/torrc` and add the following: + +```sh +HiddenServiceDir /var/lib/tor/monerod + +# For wallets connecting over RPC: +HiddenServicePort 18081 127.0.0.1:18081 +# For other nodes: +HiddenServicePort 18083 127.0.0.1:18083 +``` + +Now restart Tor: +```sh +systemctl restart tor +``` + +You can acquire the Tor address by running: +```sh +cat /var/lib/tor/monerod/hostname +``` + +### I2P + +Edit `tunnels.conf` (Which may be located in `/home/i2p/.i2pd/` if you followed [this](/i2p) guide) and add the following tunnels: + +```systemd +[monerod] +type = http +host = 127.0.0.1 +port = 18083 +keys = monerod.dat + +[monerod-rpc] +type = http +host = 127.0.0.1 +port = 18081 +keys = monerod-rpc.dat +``` + +Now restart `i2pd`: +```sh +systemctl restart i2pd +``` + +You can acquire the I2P address by running: +```sh +printf "%s.b32.i2p +" $(head -c 391 /home/i2p/.i2pd/monerod.dat | sha256sum |xxd -r -p | base32 | sed s/=//g | tr A-Z a-z) +``` + +### Configuring monerod + +Then, in `/etc/monerod.conf`, add the following: + +```sh +# I2P config +tx-proxy=i2p,127.0.0.1:4447 +anonymous-inbound={{<hl>}}your-i2p-address-here.b32.i2p{{</hl>}}:80,127.0.0.1:18083,16 # Maximum 16 simultaneous connections + +# Tor config +tx-proxy=tor,127.0.0.1:9050,10 +anonymous-inbound={{<hl>}}your-tor-address-here.onion{{</hl>}}:18083,127.0.0.1:18083,16 +``` + +## Running the Node + +Then, run this command to download the systemd daemon configuration for `monerod`. This will allow your node to run in the background and start automatically on boot as a service. + +```sh +curl https://raw.githubusercontent.com/monero-project/monero/master/utils/systemd/monerod.service > {{<hl>}}/etc/systemd/system/monerod.service{{</hl>}} +``` + +*Note: This configuration assumes that you've created a user named `monero` which runs the program `monerod` in it's home directory, and which points to the configuration in `/etc/monerod.conf`. Edit any of these details in `/etc/systemd/system/monerod.service` if they don't apply to your configuration.* + +Now reload the systemd service file: +```sh +systemctl daemon-reload +``` + +To run the node, restart the systemd service: +```sh +systemctl restart monerod +``` + +To monitor the node's status at any time (for example, to check sync progress) check the log file using `tail`: +```sh +tail -f /var/log/monero/monerod.log +``` + +## Connecting to your Node + +To connect to your node using the GUI wallet, first open it: + +{{< img src=/pix/monerod/monerod-step-1.webp >}} + +On the mode selection screen, make sure to pick **Advanced mode:** + +{{< img src=/pix/monerod/monerod-step-2.webp >}} + +When you reach daemon settings, select the **Connect to a remote node** option, and then click **add remote node.** + +{{< img src=/pix/monerod/monerod-step-3.webp >}} + +A prompt will appear, asking for your node's details. Add your **address,** set the port to **18081,** and make to click **Mark as trusted daemon.** + +{{< img src=/pix/monerod/monerod-step-4.webp >}} + +When you reach the main wallet screen, you'll see **"Remote Node"** in the bottom-left corner. Now you can enjoy using your Monero node straight from your wallet! + +{{< img src=/pix/monerod/monerod-step-5.webp >}} diff --git a/content/mumble.md b/content/mumble.md new file mode 100644 index 0000000..2c475b6 --- /dev/null +++ b/content/mumble.md @@ -0,0 +1,134 @@ +--- +title: "Mumble" +icon: 'mumble.svg' +tags: ['service'] +date: 2023-07-2 +short_desc: 'Open Source, Low Latency, High Quality Voice Chat.' +--- + +[Mumble](https://mumble.info) is an open source, low latency and high quality voice chat software, being the best open source alternative to TeamSpeak. +VoIP communications are mandatory encrypted by default using OCB-AES128, it has integrations for gamers (like overlays), it's stable and it's resource friendly. + +The server can also be run [behind Tor](https://gitlab.torproject.org/legacy/trac/-/wikis/doc/TorifyHOWTO/Mumble) without any issue. + +## Installation + +Mumble has a Debian repository for client and server, however it's very outdated so we are going to build the server instead. + +**I suggest to build both binaries on your local machine and [transfer the `mumble-server` to your remote server using `spc`](#extra).** + + +Install dependencies: +```sh +apt install build-essential cmake pkg-config qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5svg5-dev libboost-dev libssl-dev libprotobuf-dev protobuf-compiler libprotoc-dev libcap-dev libxi-dev libasound2-dev libogg-dev libsndfile1-dev libspeechd-dev libavahi-compat-libdnssd-dev libxcb-xinerama0 libzeroc-ice-dev libpoco-dev g++-multilib +``` + +Git clone the repo. + +```sh +git clone https://github.com/mumble-voip/mumble.git && cd mumble +``` + +Initialize all the submodules. + +``` +git submodule update --init +``` + +Create a build directory and run `cmake`. +Cmake will create all the necessary files to build the mumble-server and client. + +```sh +mkdir build && cd build && cmake .. +``` + +Build using `cmake`. + +```sh +cmake +``` + +After the build you will now find a file named `mumble-server`, one `mumble` (which is the client) and a file named `mumble-server.ini` (aka the config file). + +## Running your Mumble server + +If you built it on local machine you can check out [how to move it to your remote server](#extra) first. + +After that, start with making your `mumble-server` executable and move it in `/usr/bin`. + +```sh +chmod +x mumble-server && mv mumble-server /usr/bin +``` + +Create a folder in `/etc/` move your config files there. + +```sh +mkdir /etc/mumble && mv mumble-server.ini /etc/mumble +``` + +Now we can run the server passing the config and a superuser password that can be used to connect and authenticate as an administrator from any client + +```sh +mumble-server -ini mumble-server.ini -supw <your_password> +``` + +Check if it's running in the backgroud with `ps aux`. + +```sh +ps aux | grep mumble-server +``` + +You will have an output like this. + +```sh +root 127181 0.1 0.1 261064 21640 ? Sl 19:18 0:01 ./mumble-server +root 127689 0.0 0.1 112956 22572 ? Sl 19:19 0:00 ./mumble-server +``` + +## Connecting to your mumble-server as a SuperUser + +You will probably will be left with your `mumble` binary in the build folder on your local machine. + +Now you should make it executable and move it in the `/usr/bin` folder. + +```sh +chmod +x mumble && mv mumble /usr/bin +``` + +Run it the GUI with one command. + +```sh +mumble +``` + +You will have something like this opening up. + +{{< img src="/pix/mumble/mumble-1.png" alt="connect window" >}} + +Click on the button `Add New...` and fill out the information need to connect to your server. + +{{< img src="/pix/mumble/mumble-2.png" alt="add server window" >}} + +If you haven't edited the port, `64738` will be default one. + +Click on `Ok`, select your server from the list and click `Connect`. + +**Now you are connected to your very own Mumble server as a SuperUser!** + +--- + +## Extra + +### Move binary with scp + +Move your binary to the folder `~` of your remote server. + +```sh +spc <your_binary> root@<your_server_ip>:~ +``` + +--- + +Written by [NotMtth](https://notmtth.xyz) (Tor access warning) + +Donate Monero at: `donate.notmtth.xyz` ([OpenAlias](https://openalias.org/))
\ No newline at end of file diff --git a/content/prosody.md b/content/prosody.md index 2797a8e..08262ab 100644 --- a/content/prosody.md +++ b/content/prosody.md @@ -96,21 +96,18 @@ apt install prosody-modules Then we can add the following line to you prosody config file to enable file uploads: ```cfg -Component "uploads.example.org" "http_upload" +Component "{{<hl>}}uploads.example.org{{</hl>}}" "http_file_share" ``` As you will notice, you need another subdomain for this. We will add an ssl certficate for this later. -You will also need to go back to `modules_enabled` and uncomment the `http_files` module. -This is used to actually serve the files to users. - ### Proxy Support This helps with file transfers for devices behind a NAT, and unless you are using XMPP in a LAN, you **probably need this.** Enable the proxy by adding the following line to the config: ```cfg -Component "proxy.example.org" "proxy65" +Component " {{<hl>}}proxy.example.org{{</hl>}}" "proxy65" ``` As you can see, another subdomain is needed. We will add ssl certificates for this later. @@ -120,26 +117,45 @@ At this point, file sharing is now setup and ready to be used. Although there ar A big concern with file sharing is large files, seeing as all files shared over XMPP will be stored on your server. This can become a problem when many (and large) files are being shared. We can put a cap on large files by adding the following line to our config: ```cfg -http_upload_file_size_limit = 20971520 +http_file_share_file_size_limit = 20971520 ``` This puts a 20MB cap on all files being shared. The value is specified in bytes. You can also specify after how long files should be deleted by adding the following line: ```cfg -http_upload_expire_after = 60 * 60 * 24 * 7 +http_file_share_expire_after = 60 * 60 * 24 * 7 ``` The value is specified in seconds. The above line will make prosody delete files after a week. -If it is for some reason neccessary, you can also manually invoke expiry with the following command: +### Database Setup -```cfg -prosodyctl mod_http_upload expire +Prosody includes the `internal` and `sql` storage backends by default. +If you wish to run Prosody with PostgreSQL, begin by installing the PostgreSQL: + +```sh +apt install postgresql ``` -### Database Setup +Then start the daemon: + +```sh +systemctl restart postgresql +``` -Prosody includes the `internal` and `sql` storage backends by default. If you wish to run Prosody with PostgreSQL, edit the following lines: +Now create a user named `prosody` to manage your database: + +```sh +su -c "createuser --pwprompt prosody" postgres +``` + +And finally, create the actual database: + +```sh +su -c "psql -c 'CREATE DATABASE prosody OWNER prosody;'" postgres +``` + +Finally, in `/etc/prosody/prosody.cfg.lua`, edit the following lines: ```cfg storage = "sql" @@ -153,8 +169,6 @@ sql = { } ``` -(This is assuming you've installed the `postgresql` package, and setup a database named `prosody` with a user named `prosody` as the owner.) - ### Voice and Video Calling Prosody supports XMPP voice and video calls through an external TURN and STUN server. @@ -194,14 +208,14 @@ Obviously, we want to have client-to-server and server-to-server encryption. Now **If you have multi-user chat enabled, be sure to get a certificate for that subdomain as well.** Include the `--nginx` option assuming you have an Nginx server running. ```sh -certbot -d chat.example.org --nginx +certbot -d {{<hl>}}chat.example.org{{</hl>}} --nginx ``` **If you have file sharing enabled, be sure to get a certificate for those subdomains as well.** ```sh -certbot -d uploads.example.org --nginx -certbot -d proxy.example.org --nginx +certbot -d {{<hl>}}uploads.example.org{{</hl>}} --nginx +certbot -d {{<hl>}}proxy.example.org{{</hl>}} --nginx ``` Once you have the certificates for encryption, run the following to import them into Prosody. @@ -219,7 +233,7 @@ Note that you might get an error that a certificate has not been found if your ` Let's manually create the admin user we prepared for above. Note that you can indeed do this in your XMPP client if you have not disabled registration, but this is how it is done on the command line: ```sh -prosodyctl adduser chad@example.org +prosodyctl adduser {{<hl>}}chad@example.org{{</hl>}} ``` This will prompt you to create a password as well. @@ -259,6 +273,6 @@ Remember that MUCs are kept on a separate subdomain that we created and should'v ### Note on firewalls and opening ports -If you use a firewall, you should open ports 5222 and 5281. The first one is needed for clients to be able to connect to your server. The second is only necessary if you are using the `http_upload` module for file sharing. +If you use a firewall, you should open ports 5222 and 5281. The first one is needed for clients to be able to connect to your server. The second is only necessary if you are using the `http_file_share` module for file sharing, as 5281 is the port for serving content over HTTPS. A complete list of ports used by Prosody can be found [here](https://prosody.im/doc/ports). diff --git a/content/radicale.md b/content/radicale.md index b24f8ef..c37f22c 100644 --- a/content/radicale.md +++ b/content/radicale.md @@ -49,6 +49,12 @@ Execute the following command to add a new user to Radicale. htpasswd -B -c /etc/radicale/users username ``` +To create additional users, htpasswd is used again but without the additional modifier. + +```sh +htpasswd -B /etc/radicale/users username2 +``` + As Radicale stands now it is fully functional and after starting it by executing its binary, can be accessed under example.org:5232. But there are two additional things we can do to make using and managing Radicale diff --git a/content/transmission.md b/content/transmission.md new file mode 100644 index 0000000..4930661 --- /dev/null +++ b/content/transmission.md @@ -0,0 +1,844 @@ +--- +title: "Transmission" +date: 2023-07-22 +icon: "transmission.png" +tags: ["service"] +short_desc: "Decentralized file-sharing with BitTorrent." +--- + +[Transmission] allows you to send and receive files via the BitTorrent +protocol. This tutorial shows you how to use Transmission to run a +"seedbox" - a server for downloading and seeding torrents. + +(For an explanation of BitTorrent, see [Appendix 1].) + +[Transmission]: https://transmissionbt.com/ +[Appendix 1]: #appendix-1-what-is-bittorrent + +## Installation + +The Transmission daemon is available in the Debian repositories: + +```sh +apt install transmission-daemon +``` + +Besides installing Transmission, this command creates: +* A user for running the service (`debian-transmission`) +* A default configuration file + (`/var/lib/transmission-daemon/info/settings.json`) +* A default service file + (`/etc/systemd/system/multi-user.target.wants/transmission-daemon.service`) + +## Configuration + +### Transmission-Daemon + +Any time you need to modify Transmission\'s configuration, you must stop +the `transmission-daemon` service. Otherwise, Transmission will +overwrite your changes. + +```sh +service transmission-daemon stop +``` + +Open `/var/lib/transmission-daemon/info/settings.json` to view +Transmission\'s configuration. The file should look something like this: + +```json +{ + "alt-speed-down": 50, + "alt-speed-enabled": false, + "alt-speed-time-begin": 540, + "alt-speed-time-day": 127, + "alt-speed-time-enabled": false, + "alt-speed-time-end": 1020, + "alt-speed-up": 50, + "bind-address-ipv4": "0.0.0.0", + "bind-address-ipv6": "::", + "blocklist-enabled": false, + "blocklist-url": "http://www.example.com/blocklist", + "cache-size-mb": 4, + "dht-enabled": true, + "download-dir": "/var/lib/transmission-daemon/downloads", + "download-limit": 100, + "download-limit-enabled": 0, + "download-queue-enabled": true, + "download-queue-size": 5, + "encryption": 1, + "idle-seeding-limit": 30, + "idle-seeding-limit-enabled": false, + "incomplete-dir": "/var/lib/transmission-daemon/Downloads", + "incomplete-dir-enabled": false, + "lpd-enabled": false, + "max-peers-global": 200, + "message-level": 1, + "peer-congestion-algorithm": "", + "peer-id-ttl-hours": 6, + "peer-limit-global": 200, + "peer-limit-per-torrent": 50, + "peer-port": 51413, + "peer-port-random-high": 65535, + "peer-port-random-low": 49152, + "peer-port-random-on-start": false, + "peer-socket-tos": "default", + "pex-enabled": true, + "port-forwarding-enabled": false, + "preallocation": 1, + "prefetch-enabled": true, + "queue-stalled-enabled": true, + "queue-stalled-minutes": 30, + "ratio-limit": 2, + "ratio-limit-enabled": false, + "rename-partial-files": true, + "rpc-authentication-required": true, + "rpc-bind-address": "0.0.0.0", + "rpc-enabled": true, + "rpc-host-whitelist": "", + "rpc-host-whitelist-enabled": true, + "rpc-password": "{224c4b5e26569d0baa8a161a68263253bbc69c26dnhxDeWg", + "rpc-port": 9091, + "rpc-url": "/transmission/", + "rpc-username": "transmission", + "rpc-whitelist": "127.0.0.1", + "rpc-whitelist-enabled": true, + "scrape-paused-torrents-enabled": true, + "script-torrent-done-enabled": false, + "script-torrent-done-filename": "", + "seed-queue-enabled": false, + "seed-queue-size": 10, + "speed-limit-down": 100, + "speed-limit-down-enabled": false, + "speed-limit-up": 100, + "speed-limit-up-enabled": false, + "start-added-torrents": true, + "trash-original-torrent-files": false, + "umask": 18, + "upload-limit": 100, + "upload-limit-enabled": 0, + "upload-slots-per-torrent": 14, + "utp-enabled": true +} +``` + +Here are the options you should definitely look at: +1. `download-dir` specifies where Transmission should save downloaded + torrents. (You can probably leave this at the default of + `/var/lib/transmission-daemon/downloads`.) If you change this, make + sure `debian-transmission` has permissions to use the directory. +2. `peer-port` specifies what port Transmission should listen on to + connect to peers. (You can probably leave this at the default of + `51413`.) +3. `rpc-password` specifies the password required to control + Transmission. Change this by typing it in as plaintext. When the + Transmission service starts, it will be hashed and prefixed with a + left curly bracket (`{`). +4. `rpc-port` specifies the port Transmission will listen on for remote + commands. (You can probably leave this at the default of `9091`, + unless you have another service listening on this port for some + reason.) +5. `rpc-username` specifies the username required to control + Transmission. The default is `transmission`, but feel free to change + this. + +### Firewall + +If `peer-port-random-on-start` is set to the default of `false`, your +firewall must allow TCP and UDP traffic on the `peer-port`. Assuming you +are using `ufw`, and `peer-port` is at the default of `51413`, enter: + +```sh +ufw allow 51413 +``` + +#### Note on Port Randomization + +If you set `peer-port-random-on-start` to `true`, your firewall must +allow both TCP and UDP traffic on the port range specified by +`peer-port-random-low` and `peer-port-random-high`. + +Assuming you are using `ufw`, and `peer-port-random-high` is `65535`, +and `peer-port-random-low` is `49152`, enter: + +```sh +ufw allow 49152:65535/tcp +ufw allow 49152:65535/udp +``` + +### Starting the Service + +After modifying and saving the `transmission-daemon` configuration, +start the service: + +```sh +service transmission-daemon start +``` + +Transmission will hash your password in the configuration. You should be +able to connect to the daemon with `transmission-remote` locally on the +server using your credentials as shown next. + +## Controlling Transmission Locally + +`transmission-daemon` runs your torrent session in the background. It is +controlled by an HTTP API that it serves on the `rpc-port` at +`localhost`. `transmission-remote` is the command line utility you can +use to control the daemon, and it was installed automatically when you +installed `transmission-daemon`. + +### Authentication + +You first need to authenticate `transmission-remote` using the username +and password you set up in `settings.json`. There are 2 basic ways you +can do this. + +#### .netrc File + +The first method is via a `.netrc` file in your home directory. The +advantage of this method is that you do not need to provide your +credentials every time you run a `transmission-remote` command. The +disadvantage is that your Transmission password is stored in your home +folder as plaintext. + +To add the necessary record to your `.netrc` file, run the following +command, where `<username>` is the `rpc-username`, and `<password>` is +the plaintext version of `rpc-password` in `settings.json`: + +```sh +echo "machine localhost login <username> password <password>" >> ~/.netrc +``` + +Then, to authenticate, run: + +```sh +transmission-remote --netrc +``` + +Subsequent `transmission-remote` commands will not require entering your +credentials. + +#### \-\-auth Flag + +The second method to authenticate is to include an `auth` flag in every +`transmission-remote` command you execute. Substituting your credentials +for `username` and `password`, you can enter the following command to +list your torrents: + +```sh +transmission-remote --auth=username:password --list +``` + +At this point, you should be able to use `transmission-remote` on your +server to manage your torrents. + +### Hosting Torrents + +Here is a cookbook of common `transmission-remote` commands for hosting +torrents. + +Add a torrent via a magnet link: + +```sh +transmission-remote --add "magnet:link" +``` + +Add a torrent via a .torrent file: + +```sh +transmission-remote --add "your.torrent" +``` + +List the status of your torrents (and get their numerical IDs): + +```sh +transmission-remote --list +``` + +Get information about a specific torrent (where `ID` is the torrent ID +from the prior command): + +```sh +transmission-remote --torrent=ID --info +``` + +Remove a torrent and keep its data (where `ID` is the torrent ID): + +```sh +transmission-remote --torrent=ID --remove +``` + +Remove a torrent and delete its data (where `ID` is the torrent ID): + +```sh +transmission-remote --torrent=ID --remove-and-delete +``` + +Get information about the current Transmission session: + +```sh +transmission-remote --session-info +``` + +Get statistics about the current Transmission session: + +```sh +transmission-remote --session-stats +``` + +### Downloading Completed Torrents via Secure Shell + +Completed torrent downloads will be saved in the directory indicated by +`download-dir` in your configuration. (This is +`/var/lib/transmission-daemon/downloads` by default.) + +You should be able to download those files and directories from your +seedbox using tools like [`rsync`], `(s)ftp`, and `scp`. + +[`rsync`]: ../rsync/ + +If this is sufficient for you, you do not need to configure Transmission +for remote access. + +## Creating New Torrents + +`transmission-create` is used to create torrents. It was installed +automatically on your server when you installed `transmission-daemon`. +You can use it on any machine that has it installed and has a copy of +the file or directory you want to share. + +(`transmission-edit` is also available to edit .torrent files. It can do +things like add and delete tracker urls. However, this tool tends to be +more useful when working with other\'s .torrent files and less so when +creating torrents from scratch.) + +### Creating the .torrent File + +Here is a template command for creating a .torrent file: + +```sh +transmission-create --outfile "my.torrent" \ + --comment "My cool torrent" \ + --tracker "https://tracker1.example.org/announce" \ + --tracker "https://tracker2.example.org/announce" \ + "path/to/my/file/or/directory" +``` + +* `outfile` specifies where to write the .torrent file. +* `comment` specifies a comment for the torrent. +* `tracker` specifies a torrent tracker to use. You can have multiple of + these. `udp://open.tracker.cl:1337/announce` is usually a good choice, + but there are many others. +* The path indicates the file or directory you want to make a torrent + of. + +### Generating the Magnet Link + +`transmission-show` is used to generate magnet links from .torrent +files, and it was installed when you installed `transmission-daemon`. +Given any .torrent file, you can run: + +```sh +transmission-show --magnet "my.torrent" +``` + +### Seeding Your New Torrent + +First, copy the file or directory that you are hosting to the download +directory (`download-dir`) specified in the `transmission-daemon` +configuration. If the `download-dir` is at the default, you could write: + +```sh +cp "the-file-or-directory-to-share" \ + "/var/lib/transmission-daemon/downloads/" +``` + +Then, add your torrent to Transmission via your .torrent file or magnet +link: + +```sh +transmission-remote --add "the-torrent-file-or-magnet-link" +``` + +Your server should begin seeding your torrent, and you can share it via +the .torrent file or magnet link. + +**Warning:** Make sure you copy the file or directory you are seeding to +the `download-dir` directory *before* adding the torrent to +Transmission. If you copy the source file/directory into your download +directory *after* adding the torrent, run `transmission-remote` to get +the ID of your torrent: + +```sh +transmission-remote --list +``` + +Then, where `ID` is the ID of the torrent, run this command so +Transmission will know it already has the data: + +```sh +transmission-remote --torrent=ID --verify +``` + +The torrent should then begin seeding. + +## Controlling Transmission Remotely + +At this point, you should be able to manage your seedbox locally by +using `transmission-remote` on your server via secure shell. However, it +may be convenient to also configure the box for remote access. You can +do this by exposing Transmission\'s HTTP API, which includes a web app. + +The Transmission web app acts as a graphical stand-in for +`transmission-remote`. You can manage your torrents and the daemon with +it. + +Similar to `transmission-remote` itself, however, you cannot download +completed torrents via the web app. (That requires serving the files via +a different channel, whether that be `rsync`, `sftp`, `scp`, `http(s)`, +etc. Serving completed torrents via `http(s)` is explained later.) + +Exposing Transmission\'s HTTP interface to the internet additionally +allows you to control your seedbox from a different machine using +`transmission-remote`. + +### Configuring Remote Access + +By default, `transmission-daemon` only allows RPC commands from +`localhost`. For remote access, it must allow connections from the IP +addresses you want to access the daemon from. The most direct way of +doing this is by disabling the whitelist, which allows all IP addresses, +but you can specify a whitelist if you like. + +Stop `transmission-daemon`: + +```sh +service transmission-daemon stop +``` + +Then, set `rpc-whitelist-enabled` to `false` in your configuration. This +makes it so that any IP address can connect and control +`transmission-daemon`. (You will just need your `rpc-username` and the +plaintext version of your `rpc-password` to authenticate.) + +Alternatively, if you want to use the whitelist, set +`rpc-whitelist-enabled` to `true`, and set `rpc-whitelist` to a +comma-separated list of IP addresses. (Asterisks are used as wildcards.) +For example, you could write: + +``` +101.125.137.168,89.72.*.221 +``` + +While you have the configuration open, take note of the value of +`rpc-port`, which is 9091 by default. This value will be necessary for +configuring remote access. + +After saving your configuration, start `transmission-daemon`: + +```sh +service transmission-daemon start +``` + +### Running Nginx as a Reverse Proxy + +It is possible to open remote access to `transmission-daemon` simply by +opening its `rpc-port` in the firewall, 9091 by default. This connection +will be run over insecure HTTP, so your username and password will be +sent unencrypted. While this may be acceptable when testing a system, it +is generally preferable to use a web server with TLS as a reverse proxy +to Transmission\'s HTTP interface. + +If you are already running nginx with working TLS, allowing access to +Transmission\'s web interface simply requires adding a `location` block +to your `server` block in your nginx configuration. Assuming `rpc-port` +is 9091, and `rpc-url` is `/transmission/` in your `transmission-daemon` +configuration, add the following block to your nginx configuration: + +```nginx +location /transmission/ { + proxy_pass http://localhost:9091/transmission/ ; +} +``` + +Reload nginx so your changes takes effect: + +```sh +nginx -s reload +``` + +At this point, if `example.org` is your domain, and you are connected +from a permitted IP address: +* The Transmission web app will be available at + `https://example.org/transmission/web/`. +* `transmission-remote` will be able to connect to + `https://example.org/transmission`. (Note the omission of the trailing + forward slash.) + +#### Serving Transmission at a Different Path + +By default, Transmission serves it\'s interface at the path +`/transmission/`. You can change this in the configuration, but note +that your chosen path must start and end with a forward slash. + +For example, to serve Transmission\'s interface at `/~luke/torrents/`: + +1. Stop the `transmission-daemon` service. +2. Set `rpc-url` in the configuration to your chosen path. That is + `/~luke/torrents/` in this example. +3. Modify the `location` block\'s path pattern and `proxy_pass` url in + your nginx configuration to use the new path (and the correct + `rpc-port`). For this example, that is: + +```nginx +location /~luke/torrents/ { + proxy_pass http://localhost:9091/~luke/torrents/ ; +} +``` + +4. Start the `transmission-daemon` service. +5. Reload nginx. + +The Transmission web app will then be accessible at +`https://example.org/~luke/torrents/web/`. `transmission-remote` will be +able to connect to `https://example.org/~luke/torrents`. + +### Connecting via a Browser + +Where `example.org` is your website, and `/transmission/` is the +`rpc-url` in your `transmission-daemon` configuration, point your web +browser to `https://example.org/transmission/web/`. After entering your +credentials into the login (using your `rpc-username` and plaintext +`rpc-password`), you will be greeted by the web interface with a list of +your torrents. + +Here is a Transmission instance that is downloading one torrent: + +{{<img src="/pix/transmission-web-interface.png" + alt="A screenshot of the Transmission web interface" >}} + +### Connecting via Transmission-Remote + +You can control `transmission-daemon` on your server from other machines +that have `transmission-remote` installed. You do this by calling +`transmission-remote` with a url consisting of the domain name (or IP), +the `rpc-port`, and the path specified by `rpc-url` in the configuration +(`/transmission/` by default) with the trailing forward slash omitted. +For example, after inserting your credentials for `username` and +`password`, assuming the `rpc-url` is at the default of +`/transmission/`, you could invoke the following command on your local +machine to list the status of the torrents on your server: + +```sh +transmission-remote https://example.org/transmission \ + --auth=username:password \ + --list +``` + +Note how the `rpc-url` is `/transmission/`, but `/transmission` is +specified in the command. + +**Warning:** The Transmission web app and `transmission-remote` both +allow you to make changes to Transmission\'s port settings. Be careful +change these, because you might also need to update your server\'s +firewall configuration. + +## Serving Complete Torrent Downloads via HTTP(S) + +The Transmission web interface and `transmission-remote` do not allow +you to download completed torrents from your seedbox via HTTP(S). +However, in some scenarios, downloading via HTTP(S) may be preferable +where shell access and other supporting tools (`rsync`, `scp`, `sftp`, +`ftp`, etc.) are unavailable on the client machine. Serving completed +torrent downloads involves configuring nginx to serve the `download-dir` +of `transmission-daemon`. + +(Serving completed torrent downloads via HTTP(S) does not require +exposing Transmission\'s HTTP API and web app.) + +**Warning:** The Transmission interfaces give you the option of saving +completed torrent downloads to directories other than the `download-dir` +specified in your `transmission-daemon` configuration. Downloading a +torrent to a different directory and not serving that directory with +nginx will prevent that completed torrent from being served to clients +via the static file server shown here. + +Assuming you wish to serve your completed torrents from the directory +`/downloads/` on your web server, and `download-dir` is at the default +of `/var/lib/transmission-daemon/downloads/`, you can add this +`location` block into the `server` block of your nginx configuration: + +```nginx +location /downloads { + root /var/lib/transmission-daemon/downloads ; + proxy_max_temp_file_size 0 ; + autoindex on ; +} +``` + +Note how the trailing forward slash has been omitted in both the +`location` pattern and the `root` path. + +The `proxy_max_temp_file_size` option prevents disk caching that would +potentially break nginx\'s ability to serve files larger than a few +gigabytes. + +If you omit the `autoindex` option or set it to `off`, nginx will not +show a directory listing of your downloaded torrents. (You will need the +direct link to download a given torrent.) + +After saving the configuration, reload nginx. + +Where `example.org` is your website, and assuming `autoindex` is `on`, +opening `https://example.org/downloads/` in a web browser should show a +list of links to download your completed torrents. + +While downloading via HTTP(S) can be convenient, resuming interrupted +downloads can be a nuisance. See [Appendix 2] for tips on how to combat +this. + +[Appendix 2]: #appendix-2-reliable-downloading-via-https + +### Preventing Unauthorized Downloading + +If you want to prevent others from downloading completed torrents via +HTTP(S) from your seedbox, you have a few options: +1. When defining the nginx `location` block, you can use some random + string for the path match pattern, like `/DJRmdL8HPn`. Only those who + know the path will able to download your completed torrents. +2. You can protect the directory with a username and password using + [HTTP basic authentication]. + +[HTTP basic authentication]: ../auth/ + +## Troubleshooting + +`journalctl` can be used to view the logs of `transmission-daemon`. For +example, you could run: + +```sh +journalctl | grep transmission-daemon +``` + +Transmission\'s [documentation] contains help and answers to common +questions. + +[documentation]: + https://github.com/transmission/transmission/blob/main/docs/README.md + +## Appendix 1: What is BitTorrent? + +Many protocols for sending files over the internet, such as Hypertext +Transfer Protocol (HTTP) and File Transfer Protocol (FTP), operate on a +\"client-server\" (or \"server-client\") model. A server will store a +file. A client will send a request for the file from the server. If the +request is accepted, the server will respond with the file. + +In contrast, BitTorrent is a decentralized, peer-to-peer, file-sharing +protocol. Instead of relying on a dedicated server, a file will be +assembled by downloading it in chunks from many different hosts. Anyone +who has the file (or pieces of it) can then help serve the file to +others. This makes file-sharing via BitTorrent much less susceptible to +data loss and downtime than the client-server model since the file can +be replicated and shared across a potentially large number of +independent hosts. + +The individual hosts are called \"peers\". The process of a host +offering their copy of the file for download to others is called +\"seeding\". The set of peers collectively hosting the file is called a +\"swarm\". + +The peers usually find out about each other using \"trackers\", +dedicated servers that help peers find those who possess or want a +specific file. Trackers are identified by URLs. A peer can \"announce\" +to a tracker that it possesses a specific file. If a peer wants to +download a file, the peer can ask the tracker for peers that possess the +file. Trackers do not actually transfer the torrent between peers. They +simply facilitate peer-discovery. + +The BitTorrent network also uses other mechanisms for peer-discovery, +including a \"DHT\", or Distributed Hash Table. Similar to trackers, +these help peers find each other. Unlike trackers, a DHT is entirely +peer-to-peer as it is based on a distributed data structure rather than +a dedicated server. The DHT that BitTorrent uses is called the Mainline +DHT. Most modern torrent clients will give you the option of using it to +help you find peers. (Transmission supports it.) + +Before downloading a desired file or directory, you will need its +.torrent file or magnet link. These are usually distributed via +webpages, and they contain metadata and other information required for +downloading the file, including: +* The cryptographic hash of the file for validating its integrity. (A + .torrent file will also include hashes for individual chunks of the + file.) +* The name of the torrent. +* A list of tracker URLs to use for finding peers. + +Once the .torrent file or magnet link has been imported into a torrent +client, the client will query the network to discover peers that possess +the file. The swarm will then work together to send the user the file in +chunks. The chunks will be cryptographically validated and assembled to +create the final file. After the user has downloaded the file (or even +if they only have pieces of it), they also can be part of the swarm by +helping to seed the file to others who want it. + +\"Leeching\" is when a user downloads torrents and does not seed them to +others. This practice hurts the overall functioning of the swarm and +will also usually reduce the bandwidth that other peers are willing to +dedicate to you in the future. Always reseed. 🌱 + +## Appendix 2: Reliable Downloading via HTTP(S) + +Downloading via HTTP(S) can be very convenient when shell access is +unavailable. It can also be very troublesome with large files due to +interrupted or corrupted downloads. Thankfully, utilities like `wget` +and `zsync` can help combat this. + +### wget + +`wget` supports resuming interrupted downloads. It isn\'t as robust for +this use case as other utilities (like `zsync`), but it can be +convenient because: +* It doesn\'t require any extra setup on your server. +* It comes preinstalled on most \*nix systems. + +Supposing you want to download a very large file from your web server +and save it to your current directory, you might run: + +```sh +wget https://example.org/downloads/large.file +``` + +If this command is stopped or interrupted, running it again with the +`--continue` flag will cause `wget` to resume your download: + +```sh +wget --continue https://example.org/downloads/large.file +``` + +If your network connection is particularly poor, you can also specify +the `--tries=0` flag. `wget` will retry connecting indefinitely, so you +don\'t need to run the command multiple times if it disconnects. + +One major downside of using `wget` is that the resumption of the +download is based on the difference between the file length on the +server and the length of the partial file on your disk. No cryptography +or checksum is used to validate the file's integrity. + +`wget` also supports downloading directories, but this can be finicky. +You might need to experiment with the arguments depending on the +contents of the directory. For example, assuming directory listing is +enabled in the relevant directory on your web server, you might run a +command like: + +```sh +wget --recursive --no-parent \ + https://example.org/downloads/large-directory/ +``` + +The `--recursive` flag indicates that `wget` should download the +contents of the directory as well as its subdirectories up to 5 levels +deep. + +The `--no-parent` flag indicates that `wget` should not download any +files at higher levels in the directory hierarchy. + +**Note:** Enabling `autoindex` for a directory in nginx implicitly +creates `index.html` files in the directory and its subdirectories from +the perspective of HTTP(S) clients like `wget`. However, the `--reject +index.html` flag is omitted in the above command because `wget` needs +the links in those index files to download all of the files in the +target directory. (In fact, for this reason, the above command might +potentially fail to download all the files in the directory if the +target directory contains `index.html` files.) Once the directory has +been downloaded to your disk, you would then need to delete the +`index.html` files that were created by the web server's directory +listing in your downloaded copy. Additionally, the actual directory +structure created on your disk with this example would be +`example.org/downloads/large-directory/`, not `large-directory/`. + +### zsync + +`zsync` is another option for more reliable HTTP(S) downloading. + +The advantages of `zsync` include: +* It offers significantly more data validation than `wget` by using + hashes and checksums. +* By using the `-i` flag, you can specify file chunks you have on disk + from the same or similar downloads to potentially accelerate the + current download. + +The disadvantages of `zsync` include: +* It does not usually come pre-installed on *nix systems. +* Unlike `wget`, it does not support downloading directories. It only + supports files. +* It must be installed on the client-side. +* It requires additional setup on the server-side. + +`zsync` is available in the Debian repositories. Install it on your +server by running: + +```sh +apt install zsync +``` + +(You will also need to install it on your client machine.) + +On your server, change your directory to your torrent download +directory, `/var/lib/transmission-daemon/downloads/` by default. Then, +run `zsyncmake` by providing the url and name of the file you want to +use `zsync` on: + +```sh +zsyncmake -u "https://example.org/downloads/large.file" large.file +``` + +This will create a new file with the same name as your original file but +with the `.zsync` extension added: `large.file.zsync` in this case. +(Note that if the file you are sharing changes, you need to regenerate +the `.zsync` file.) + +If you view your torrent download directory in a browser, and nginx has +`autoindex` turned `on`, you should notice the addition of the `.zsync` +file in the directory. + +On your HTTP(S) client, where the provided url is the link to the new +`.zsync` file, run: + +```sh +zsync "https://example.org/downloads/large.file.zsync" +``` + +If your download is interrupted, just run the command again, and `zsync` +will read your partial download, resume it, checksum it, and cleanly +assemble the target file, `large.file`. + +If your downloads directory is protected with HTTP basic authentication, +you can specify your credentials by adding an `-A` flag before the URL: + +```sh +zsync -A example.org=username:password \ + "https://example.org/downloads/large.file.zsync" +``` + +If you have a piece of the file with a different name or a different +version of the file, you can specify those pieces with the `-i` flag to +potentially reduce what `zsync` needs to fetch over the network: + +```sh +zsync -i "large.file.piece" -i "large.file.old" \ + "https://example.org/downloads/large.file.zsync" +``` + +`zsync` will attempt to look for file chunks in `large.file.piece` and +`large.file.old` that can be used to help assemble `large.file`. + +For example, if you have a Linux ISO on your computer, and you want to +download an updated version from your seedbox, there\'s a good chance +that only certain sections of the ISO changed from the version you +already have. You can specify the old version of the ISO you have with +the `-i` flag to potentially reuse chunks from the old version when +downloading the new ISO. + +--- + +*Written by: Luke Hamann* diff --git a/content/wireguard.md b/content/wireguard.md index 93e722f..3e7d571 100644 --- a/content/wireguard.md +++ b/content/wireguard.md @@ -1,8 +1,9 @@ --- -title: "Wireguard" -date: 2022-07-26 -icon: 'wireguard.svg' -tags: ['service'] +title: Wireguard +date: 2022-07-26T00:00:00.000Z +icon: wireguard.svg +tags: + - service short_desc: "Fast, Modern, Secure VPN Tunnel" --- @@ -16,6 +17,7 @@ As an example, we'll be using a virtual 172.16.0.0/24 network, but any private i ## Installation ### On the Server + Install the WireGuard management tools: apt install wireguard @@ -29,6 +31,7 @@ Run the following command to apply the change: sysctl -w net.ipv4.ip_forward=1 ### On the Client + Use your package manager to install the WireGuard Management Tools. On Arch and Fedora based distros the package is `wireguard-tools`. For Debian based, it's listed above. @@ -37,7 +40,6 @@ Create the public and private keys for your machine: sudo bash -c "umask 077 ; wg genkey > /etc/wireguard/client_priv.key" sudo bash -c "wg pubkey < /etc/wireguard/client_priv.key > /etc/wireguard/client_pub.key" - ### Back to the Server Generate the public and private keys for your server: @@ -106,6 +108,7 @@ there's a good chance you're behind a corporate firewall. Read on. ## WebSocket Tunnel #### Note on TLS + If your server hosts a website with https, you won't be able to use port 443 to obfuscate your WireGuard packets as TLS traffic. You may use some other innocuous port, but there's no guarantee you'll punch through the picky firewall. @@ -145,7 +148,7 @@ Download and install wstunnel and a helper script: wget https://github.com/erebe/wstunnel/releases/download/v4.0/wstunnel-x64-linux sudo mv wstunnel-x64-linux /usr/local/bin/wstunnel sudo chmod +x /usr/local/bin/wstunnel - wget https://codeberg.org/onasaft/sbx/raw/branch/main/vpn/wstunnel.sh + wget https://raw.githubusercontent.com/jnsgruk/wireguard-over-wss/master/wstunnel.sh sudo mv wstunnel.sh /etc/wireguard/wstunnel.sh sudo chmod +x /etc/wireguard/wstunnel.sh |
