summaryrefslogtreecommitdiff
path: root/html
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2021-08-27 03:08:43 +0100
committerdavidovski <david@sendula.com>2021-08-27 03:08:43 +0100
commit459fa8f48a8d91fe2ed7eb15b093c3346d17d129 (patch)
treedbce97edf0365812d920648030a5820e97a6b5c2 /html
parente6eaad2eb74de4c4992d98ad6ddd2a35523cef96 (diff)
new article, added background
Diffstat (limited to 'html')
-rw-r--r--html/blog/entries/blarg.html11
-rw-r--r--html/blog/entries/test my blog.html11
-rw-r--r--html/blog/entries/test.html11
-rw-r--r--html/blog/index.html39
-rw-r--r--html/blog/src/blarg.md3
-rw-r--r--html/blog/src/test my blog.md5
-rw-r--r--html/blog/src/test.md3
-rw-r--r--html/entries/Permanent SSH Forwarding.html84
-rw-r--r--html/entries/ssh_forwarding.html87
-rw-r--r--html/entries/welcome.html6
-rw-r--r--html/images/bg.pngbin0 -> 828134 bytes
-rw-r--r--html/images/remotecontrol.pngbin0 -> 20363 bytes
-rw-r--r--html/index.html32
-rw-r--r--html/rss.xml52
-rw-r--r--html/src/ssh_forwarding.md74
-rw-r--r--html/style.css64
16 files changed, 385 insertions, 97 deletions
diff --git a/html/blog/entries/blarg.html b/html/blog/entries/blarg.html
deleted file mode 100644
index 2b8b489..0000000
--- a/html/blog/entries/blarg.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>blarg</title>
-</head>
-<body>
- <h1>blarg</h1>
-<p>blarg blarg test haha</p>
-</body>
-</html>
diff --git a/html/blog/entries/test my blog.html b/html/blog/entries/test my blog.html
deleted file mode 100644
index 6af39a4..0000000
--- a/html/blog/entries/test my blog.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>test my blog</title>
-</head>
-<body>
- <h1>test my blog</h1>
-<p>this is an entry woooooooooooow</p>
-</body>
-</html>
diff --git a/html/blog/entries/test.html b/html/blog/entries/test.html
deleted file mode 100644
index 94642ad..0000000
--- a/html/blog/entries/test.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>test</title>
-</head>
-<body>
- <h1>test</h1>
-<p>test testing lol</p>
-</body>
-</html>
diff --git a/html/blog/index.html b/html/blog/index.html
deleted file mode 100644
index 1c92525..0000000
--- a/html/blog/index.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title></title>
-</head>
-<body>
- <h1>blog test</h1>
- <div class="entries">
- <div>
- <h1>test</h1>
-<p>test testing lol</p>
-
- ...
- <a href="www.example.com/entries/test.html">more</a>
- <p>Date: Sun, 08 Aug 2021</p>
-</div>
-
-<div>
- <h1>blarg</h1>
-<p>blarg blarg test haha</p>
-
- ...
- <a href="www.example.com/entries/blarg.html">more</a>
- <p>Date: Sun, 08 Aug 2021</p>
-</div>
-
-<div>
- <h1>test my blog</h1>
-<p>this is an entry woooooooooooow</p>
-
- ...
- <a href="www.example.com/entries/test my blog.html">more</a>
- <p>Date: Sun, 08 Aug 2021</p>
-</div>
-
- </div>
-</body>
-</html>
diff --git a/html/blog/src/blarg.md b/html/blog/src/blarg.md
deleted file mode 100644
index 8ba38dd..0000000
--- a/html/blog/src/blarg.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# blarg
-
-blarg blarg test haha
diff --git a/html/blog/src/test my blog.md b/html/blog/src/test my blog.md
deleted file mode 100644
index d4b4bb8..0000000
--- a/html/blog/src/test my blog.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# test my blog
-
-
-this is an entry woooooooooooow
-
diff --git a/html/blog/src/test.md b/html/blog/src/test.md
deleted file mode 100644
index cef0e58..0000000
--- a/html/blog/src/test.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# test
-
-test testing lol
diff --git a/html/entries/Permanent SSH Forwarding.html b/html/entries/Permanent SSH Forwarding.html
new file mode 100644
index 0000000..3df3af7
--- /dev/null
+++ b/html/entries/Permanent SSH Forwarding.html
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <link rel="stylesheet" href="/style.css">
+ <title>davidovski.xyz</title>
+ </head>
+ <body>
+ <div class="main">
+ <div class="header">
+ <a href="https://davidovski.xyz/"<h1 class="title">davidovski.xyz</h1></a>
+ <hr>
+ <div class="links">
+ <a href="https://github.com/davidovski">git</a>
+ |
+ <a href="https://osu.ppy.sh/users/11140827">osu</a>
+ |
+ <a href="https://myanimelist.net/animelist/davidovski">mal</a>
+ |
+ <a href="https://orangepeel.pw/">op</a>
+ ||
+ <a style="color: var(--red);" href="https://davidovski.xyz/m">m</a>
+ |
+ <a style="color: var(--red);" href="https://davidovski.xyz/f">f</a>
+ |
+ <a style="color: var(--red);" href="https://davidovski.xyz/s">s</a>
+ ||
+ <a style="color: var(--green)" href="http://chat.davidovski.xyz/">chat</a>
+ |
+ <a style="color: var(--green)" href="mailto:david@davidovski.xyz">mail</a>
+ |
+ <a style="color: var(--green)" href="/rss.xml">rss</a>
+ </div>
+ </div>
+
+ <hr>
+ <h1>Permanent SSH Forwarding</h1>
+<p>Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. However, what if you don't want to, <em>or can't</em>, directly open ports onto your home network, or you if you simply want to keep all of your site on one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. </p>
+<h2>ssh remote port forwarding</h2>
+<p>SSH remote port forwarding is built right into ssh itself, and is quite simple:</p>
+<p><code>ssh -R 5505:localhost:4404 user@remote.host</code></p>
+<p>When this command is run on the local server, it will create an ssh connection to the remote server, as per usual. Additionally, it will open the port 5505 on the remote server, which will forward all traffic to port 4404 on the local server. This command by itself is already everything you'd need to forward most ports easily to your remote server, of course, remember to open the port on your remote server's firewall, if applicable.</p>
+<p>However to ensure that that port is exposed properly on the remote server, you'd want to make sure that it is listening to all external traffic. You can fix this by setting <code>GatewayPorts yes</code> in <code>/etc/ssh/sshd_config</code> on the remote server. (don't forget to restart sshd after editing the config)</p>
+<h2>Persistent ssh forwarding</h2>
+<p>The above is all well and good, but you'd need to keep an interactive ssh connection up at all times (not impossible with a tool like <code>screen</code> or <code>tmux</code>), so it isn't the most ideal solution. To get around this, you can create a service to run on the local server to forward requested ports to the remote server.</p>
+<p>To begin, I'd recommend creating two users, one on each server. For sake of example, lets all them <code>bridge</code>, though any other names like <code>tunnel</code> or whatever would work too. I'd recommend to avoid giving these users passwords, that way they can only be signed in through key based authentication. Of course you will still be able to log into them as root using <code>su - bridge</code></p>
+<p>Next you should create an ssh keypair on the local server(<code>ssh-keygen</code>) and place the contents of your public key into <code>.ssh/authorized_keys</code>. This will make sure that only the local server will be able to ssh into the remote using that key.</p>
+<p>Then, create a script for your ssh port forwarding. I placed mine directly in the home folder of my bridge user of my local server, though it only matters that the bridge user can execute it. In your script you <em>must</em> use the <code>-nT</code> flag on your ssh command. These will allow you to run this script as a service, by preventing a virtual terminal being allocated. (read <code>man ssh</code> for more info)</p>
+<p>Here is my example of a script that you could use:</p>
+<p>```sh</p>
+<h1>!/bin/sh</h1>
+<p>PORTS="8080 25565"
+DEST="bridge@remote.host"
+SSH_PORT="22"
+IDENTITY_FILE="~/.ssh"</p>
+<p>/usr/bin/ssh -nNT $(echo $PORTS | awk -v host=$LOCALHOST '{for (i = 1; i &lt;= NF; i++){ printf "-R %d:%s:%d ",$i,host,$i}}') -p $SSH_PORT -i $IDENTITY_FILE $DEST
+```</p>
+<p>Next you'd want to run this script as a service. Check your distro's service system how to do this if you have any trouble.</p>
+<h3>Systemd service</h3>
+<p>Say that the script you made was <code>/home/bridge/tunnel.sh</code>, you should create a user service with systemd for the bridge user.</p>
+<p>To do this create the following file in <code>/home/bridge/.config/systemd/user/tunnel.service</code>:</p>
+<p>```service
+[Unit]
+Description=SSH tunnel</p>
+<p>[Service]
+ExecStart=/home/bridge/tunnel.sh
+RestartSec=5
+Restart=always
+KillMode=mixed</p>
+<p>[Install]
+WantedBy=default.target
+```</p>
+<p>Then enable and start the service with: <code>systemd --user enable tunnel.service</code> and <code>system --user start tunnel.service</code>. Ensure that it is running with <code>systemd --user status tunnel</code></p>
+<h2>Forwarding ports smaller than 1024</h2>
+<p>As you may know, TCP/IP port numbers below 1024 are special in that normal users are not able to open, and hence forward from on the remote server. To bypass this, you can change your services to run at different ports, though this may not always be possible, for example with ports 80 and 443 for http and https respectively. One solution to this is run a server on the remote that will proxy requests from port 80 to a different port (say port 8080).</p>
+<p>This can be achieved using <code>socat</code>.</p>
+<p>Say you forwarded traffic from port 8080 on the remote to port 80 on the local, you could then, on the remote server run <code>sudo socat TCP-LISTEN:80,fork TCP:localhost:8080</code> to listen to traffic on port 80 and forward it to 8080, which will forward back to the local server. Here is an example of this in practice, forwarding port 80 and 443, by forwarding ports 8080 and 8443:</p>
+<p><code>/usr/bin/ssh -nT -R 8443:localhost:443 -R 8080:localhost:80 -i $IDENTITY_FILE -p $SSH_PORT $DEST "(sudo socat TCP-LISTEN:80,fork TCP:localhost:8080) &amp; sudo socat TCP-LISTEN:443,fork TCP:localhost:8443"</code></p>
+<p>However this command assumes that the remote user has access to sudo with <strong>NO PASSWORD</strong>. Alternatively you could create a similar service (this time as a system service) on the remote server running the socat commands.</p>
+ </div>
+
+ </body>
+</html>
diff --git a/html/entries/ssh_forwarding.html b/html/entries/ssh_forwarding.html
new file mode 100644
index 0000000..265d023
--- /dev/null
+++ b/html/entries/ssh_forwarding.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <link rel="stylesheet" href="/style.css">
+ <title>davidovski.xyz</title>
+ </head>
+ <body>
+ <div class="main">
+ <div class="header">
+ <a href="https://davidovski.xyz/"<h1 class="title">davidovski.xyz</h1></a>
+ <hr>
+ <div class="links">
+ <a href="https://github.com/davidovski">git</a>
+ |
+ <a href="https://osu.ppy.sh/users/11140827">osu</a>
+ |
+ <a href="https://myanimelist.net/animelist/davidovski">mal</a>
+ |
+ <a href="https://orangepeel.pw/">op</a>
+ ||
+ <a style="color: var(--red);" href="https://davidovski.xyz/m">m</a>
+ |
+ <a style="color: var(--red);" href="https://davidovski.xyz/f">f</a>
+ |
+ <a style="color: var(--red);" href="https://davidovski.xyz/s">s</a>
+ ||
+ <a style="color: var(--green)" href="http://chat.davidovski.xyz/">chat</a>
+ |
+ <a style="color: var(--green)" href="mailto:david@davidovski.xyz">mail</a>
+ |
+ <a style="color: var(--green)" href="/rss.xml">rss</a>
+ </div>
+ </div>
+
+ <hr>
+ <h1>Permanent SSH Forwarding (Tutorial)</h1>
+<p>Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. However, what if you don't want to, <em>or can't</em>, directly open ports onto your home network, or you if you simply want to keep all of your site on one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. </p>
+<h2>SSH Remote Port Forwarding</h2>
+<p>SSH remote port forwarding is built right into ssh itself, and is quite simple:</p>
+<p><code>ssh -R 5505:localhost:4404 user@remote.host</code></p>
+<p>When this command is run on the local server, it will create an ssh connection to the remote server, as per usual. Additionally, it will open the port 5505 on the remote server, which will forward all traffic to port 4404 on the local server. This command by itself is already everything you'd need to forward most ports easily to your remote server, of course, remember to open the port on your remote server's firewall, if applicable.</p>
+<p>However to ensure that that port is exposed properly on the remote server, you'd want to make sure that it is listening to all external traffic. You can fix this by setting <code>GatewayPorts yes</code> in <code>/etc/ssh/sshd_config</code> on the remote server. (don't forget to restart sshd after editing the config)</p>
+<h2>Persistent ssh forwarding</h2>
+<p>The above is all well and good, but you'd need to keep an interactive ssh connection up at all times (not impossible with a tool like <code>screen</code> or <code>tmux</code>), so it isn't the most ideal solution. To get around this, you can create a service to run on the local server to forward requested ports to the remote server.</p>
+<p>To begin, I'd recommend creating two users, one on each server. For sake of example, lets all them <code>bridge</code>, though any other names like <code>tunnel</code> or whatever would work too. I'd recommend to avoid giving these users passwords, that way they can only be signed in through key based authentication. Of course you will still be able to log into them as root using <code>su - bridge</code></p>
+<p>Next you should create an ssh keypair on the local server(<code>ssh-keygen</code>) and place the contents of your public key into <code>.ssh/authorized_keys</code>. This will make sure that only the local server will be able to ssh into the remote using that key.</p>
+<p>Then, create a script for your ssh port forwarding. I placed mine directly in the home folder of my bridge user of my local server, though it only matters that the bridge user can execute it. In your script you <em>must</em> use the <code>-nT</code> flag on your ssh command. These will allow you to run this script as a service, by preventing a virtual terminal being allocated. (read <code>man ssh</code> for more info)</p>
+<p>Here is my example of a script that you could use:</p>
+<pre><code>#!/bin/sh
+
+PORTS="8080 25565"
+DEST="bridge@remote.host"
+SSH_PORT="22"
+IDENTITY_FILE="~/.ssh"
+
+/usr/bin/ssh -nNT $(echo $PORTS | awk -v host=$LOCALHOST '{for (i = 1; i &lt;= NF; i++){ printf "-R %d:%s:%d ",$i,host,$i}}') -p $SSH_PORT -i $IDENTITY_FILE $DEST
+</code></pre>
+<p>Next you'd want to run this script as a service. Check your distro's service system how to do this if you have any trouble.</p>
+<h3>Systemd service</h3>
+<p>Say that the script you made was <code>/home/bridge/tunnel.sh</code>, you should create a user service with systemd for the bridge user.</p>
+<p>To do this create the following file in <code>/home/bridge/.config/systemd/user/tunnel.service</code>:</p>
+<pre><code>[Unit]
+Description=SSH tunnel
+
+[Service]
+ExecStart=/home/bridge/tunnel.sh
+RestartSec=5
+Restart=always
+KillMode=mixed
+
+[Install]
+WantedBy=default.target
+</code></pre>
+<p>Then enable and start the service with: <code>systemd --user enable tunnel.service</code> and <code>system --user start tunnel.service</code>. Ensure that it is running with <code>systemd --user status tunnel</code></p>
+<h2>Forwarding ports smaller than 1024</h2>
+<p>As you may know, TCP/IP port numbers below 1024 are special in that normal users are not able to open, and hence forward from on the remote server. To bypass this, you can change your services to run at different ports, though this may not always be possible, for example with ports 80 and 443 for http and https respectively. One solution to this is run a server on the remote that will proxy requests from port 80 to a different port (say port 8080).</p>
+<p>This can be achieved using <code>socat</code>.</p>
+<p>Say you forwarded traffic from port 8080 on the remote to port 80 on the local, you could then, on the remote server run <code>sudo socat TCP-LISTEN:80,fork TCP:localhost:8080</code> to listen to traffic on port 80 and forward it to 8080, which will forward back to the local server. Here is an example of this in practice, forwarding port 80 and 443, by forwarding ports 8080 and 8443:</p>
+<pre><code>/usr/bin/ssh -nT -R 8443:localhost:443 -R 8080:localhost:80 -i $IDENTITY_FILE -p $SSH_PORT $DEST "(sudo socat TCP-LISTEN:80,fork TCP:localhost:8080) &amp; sudo socat TCP-LISTEN:443,fork TCP:localhost:8443"
+</code></pre>
+<p>However this command assumes that the remote user has access to sudo with <strong>NO PASSWORD</strong>. Alternatively you could create a similar service (this time as a system service) on the remote server running the socat commands.</p>
+ </div>
+
+ </body>
+</html>
diff --git a/html/entries/welcome.html b/html/entries/welcome.html
index 48844d7..0a9caeb 100644
--- a/html/entries/welcome.html
+++ b/html/entries/welcome.html
@@ -35,14 +35,10 @@
</div>
<hr>
- <p>welcome to my site</p>
- <hr>
- <div class="entries">
- <p>welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things.</p>
+ <p>welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things.</p>
<p>originally i was going to make this blog on <a href="https://b.davidovski.xyz">b.davidovski.xyz</a> using <a href="http://nanoblogger.sourceforge.net/">nanoblogger</a> (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: <a href="https://github.com/davidovski/kblg/">kblg</a>. Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?)</p>
<p>anyway thats all for now, cya</p>
<p>~davidovski</p>
- </div>
</div>
</body>
diff --git a/html/images/bg.png b/html/images/bg.png
new file mode 100644
index 0000000..a47e8bf
--- /dev/null
+++ b/html/images/bg.png
Binary files differ
diff --git a/html/images/remotecontrol.png b/html/images/remotecontrol.png
new file mode 100644
index 0000000..5d34db5
--- /dev/null
+++ b/html/images/remotecontrol.png
Binary files differ
diff --git a/html/index.html b/html/index.html
index 4421c62..c89464d 100644
--- a/html/index.html
+++ b/html/index.html
@@ -35,10 +35,33 @@
</div>
<hr>
- <p>welcome to my site</p>
- <hr>
- <div class="entries">
- <div class="entry">
+ <div class="grid">
+ <div class="about">
+
+ <p>Hi, I'm david and this is my place in the wired where I dump various files, write blogs and whatever I feel like.</p>
+ <p>Feel free to explore the above links, or scroll through below. This site is still under contruction... permanently. So expect it to look better (or worse) in the future.</p>
+
+ <p>if you want to contact me, you can message me on matrix <code>@davidovski:matrix.org</code> (i will make my own homeserver soon ok?) or discord <code>iksvo#6239</code>. I'll be also happy to reply to any emails, linked at the top of the page</p>
+ </div>
+ <div class="image">
+ <img src="/images/remotecontrol.png">
+ </div>
+</div>
+<hr>
+<hr>
+
+<h1 class="header">blog posts</h1>
+
+
+<hr>
+<div class="entry">
+ <div class="small">Fri, 27 Aug 2021 03:01:02 <a href="https://davidovski.xyz/entries/ssh_forwarding.html">🔗</a></div>
+ <h2>Permanent SSH Forwarding (Tutorial)</h2>
+<p>Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. However, what if you don't want to, <em>or can't</em>, directly open ports onto your home network, or you if you simply want to keep all of your site on one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. </p><a href=entries/ssh_forwarding.html>read more...</a>
+</div>
+
+<hr>
+<div class="entry">
<div class="small">Sun, 08 Aug 2021 04:23:07 <a href="https://davidovski.xyz/entries/welcome.html">🔗</a></div>
<p>welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things.</p>
<p>originally i was going to make this blog on <a href="https://b.davidovski.xyz">b.davidovski.xyz</a> using <a href="http://nanoblogger.sourceforge.net/">nanoblogger</a> (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: <a href="https://github.com/davidovski/kblg/">kblg</a>. Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?)</p>
@@ -46,7 +69,6 @@
<p>~davidovski</p>
</div>
- </div>
</div>
</body>
diff --git a/html/rss.xml b/html/rss.xml
index 42c251f..df0b6ca 100644
--- a/html/rss.xml
+++ b/html/rss.xml
@@ -15,5 +15,57 @@
<p>~davidovski</p>]]></description>
</item>
+<item>
+ <title>ssh_forwarding</title>
+ <link>https://davidovski.xyz/https://davidovski.xyz/entries/ssh_forwarding.html</link>
+ <pubDate>Fri, 27 Aug 2021 03:01:02</pubDate>
+ <description><![CDATA[<h1>Permanent SSH Forwarding (Tutorial)</h1>
+<p>Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. However, what if you don't want to, <em>or can't</em>, directly open ports onto your home network, or you if you simply want to keep all of your site on one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. </p>
+<h2>SSH Remote Port Forwarding</h2>
+<p>SSH remote port forwarding is built right into ssh itself, and is quite simple:</p>
+<p><code>ssh -R 5505:localhost:4404 user@remote.host</code></p>
+<p>When this command is run on the local server, it will create an ssh connection to the remote server, as per usual. Additionally, it will open the port 5505 on the remote server, which will forward all traffic to port 4404 on the local server. This command by itself is already everything you'd need to forward most ports easily to your remote server, of course, remember to open the port on your remote server's firewall, if applicable.</p>
+<p>However to ensure that that port is exposed properly on the remote server, you'd want to make sure that it is listening to all external traffic. You can fix this by setting <code>GatewayPorts yes</code> in <code>/etc/ssh/sshd_config</code> on the remote server. (don't forget to restart sshd after editing the config)</p>
+<h2>Persistent ssh forwarding</h2>
+<p>The above is all well and good, but you'd need to keep an interactive ssh connection up at all times (not impossible with a tool like <code>screen</code> or <code>tmux</code>), so it isn't the most ideal solution. To get around this, you can create a service to run on the local server to forward requested ports to the remote server.</p>
+<p>To begin, I'd recommend creating two users, one on each server. For sake of example, lets all them <code>bridge</code>, though any other names like <code>tunnel</code> or whatever would work too. I'd recommend to avoid giving these users passwords, that way they can only be signed in through key based authentication. Of course you will still be able to log into them as root using <code>su - bridge</code></p>
+<p>Next you should create an ssh keypair on the local server(<code>ssh-keygen</code>) and place the contents of your public key into <code>.ssh/authorized_keys</code>. This will make sure that only the local server will be able to ssh into the remote using that key.</p>
+<p>Then, create a script for your ssh port forwarding. I placed mine directly in the home folder of my bridge user of my local server, though it only matters that the bridge user can execute it. In your script you <em>must</em> use the <code>-nT</code> flag on your ssh command. These will allow you to run this script as a service, by preventing a virtual terminal being allocated. (read <code>man ssh</code> for more info)</p>
+<p>Here is my example of a script that you could use:</p>
+<pre><code>#!/bin/sh
+
+PORTS="8080 25565"
+DEST="bridge@remote.host"
+SSH_PORT="22"
+IDENTITY_FILE="~/.ssh"
+
+/usr/bin/ssh -nNT $(echo $PORTS | awk -v host=$LOCALHOST '{for (i = 1; i &lt;= NF; i++){ printf "-R %d:%s:%d ",$i,host,$i}}') -p $SSH_PORT -i $IDENTITY_FILE $DEST
+</code></pre>
+<p>Next you'd want to run this script as a service. Check your distro's service system how to do this if you have any trouble.</p>
+<h3>Systemd service</h3>
+<p>Say that the script you made was <code>/home/bridge/tunnel.sh</code>, you should create a user service with systemd for the bridge user.</p>
+<p>To do this create the following file in <code>/home/bridge/.config/systemd/user/tunnel.service</code>:</p>
+<pre><code>[Unit]
+Description=SSH tunnel
+
+[Service]
+ExecStart=/home/bridge/tunnel.sh
+RestartSec=5
+Restart=always
+KillMode=mixed
+
+[Install]
+WantedBy=default.target
+</code></pre>
+<p>Then enable and start the service with: <code>systemd --user enable tunnel.service</code> and <code>system --user start tunnel.service</code>. Ensure that it is running with <code>systemd --user status tunnel</code></p>
+<h2>Forwarding ports smaller than 1024</h2>
+<p>As you may know, TCP/IP port numbers below 1024 are special in that normal users are not able to open, and hence forward from on the remote server. To bypass this, you can change your services to run at different ports, though this may not always be possible, for example with ports 80 and 443 for http and https respectively. One solution to this is run a server on the remote that will proxy requests from port 80 to a different port (say port 8080).</p>
+<p>This can be achieved using <code>socat</code>.</p>
+<p>Say you forwarded traffic from port 8080 on the remote to port 80 on the local, you could then, on the remote server run <code>sudo socat TCP-LISTEN:80,fork TCP:localhost:8080</code> to listen to traffic on port 80 and forward it to 8080, which will forward back to the local server. Here is an example of this in practice, forwarding port 80 and 443, by forwarding ports 8080 and 8443:</p>
+<pre><code>/usr/bin/ssh -nT -R 8443:localhost:443 -R 8080:localhost:80 -i $IDENTITY_FILE -p $SSH_PORT $DEST "(sudo socat TCP-LISTEN:80,fork TCP:localhost:8080) &amp; sudo socat TCP-LISTEN:443,fork TCP:localhost:8443"
+</code></pre>
+<p>However this command assumes that the remote user has access to sudo with <strong>NO PASSWORD</strong>. Alternatively you could create a similar service (this time as a system service) on the remote server running the socat commands.</p>]]></description>
+</item>
+
</channel>
</rss>
diff --git a/html/src/ssh_forwarding.md b/html/src/ssh_forwarding.md
new file mode 100644
index 0000000..bd60668
--- /dev/null
+++ b/html/src/ssh_forwarding.md
@@ -0,0 +1,74 @@
+# Permanent SSH Forwarding (Tutorial)
+
+Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. However, what if you don't want to, *or can't*, directly open ports onto your home network, or you if you simply want to keep all of your site on one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet.
+
+...
+
+## SSH Remote Port Forwarding
+
+SSH remote port forwarding is built right into ssh itself, and is quite simple:
+
+```
+ssh -R 5505:localhost:4404 user@remote.host
+```
+
+When this command is run on the local server, it will create an ssh connection to the remote server, as per usual. Additionally, it will open the port 5505 on the remote server, which will forward all traffic to port 4404 on the local server. This command by itself is already everything you'd need to forward most ports easily to your remote server, of course, remember to open the port on your remote server's firewall, if applicable.
+
+However to ensure that that port is exposed properly on the remote server, you'd want to make sure that it is listening to all external traffic. You can fix this by setting `GatewayPorts yes` in `/etc/ssh/sshd_config` on the remote server. (don't forget to restart sshd after editing the config)
+
+## Persistent ssh forwarding
+
+The above is all well and good, but you'd need to keep an interactive ssh connection up at all times (not impossible with a tool like `screen` or `tmux`), so it isn't the most ideal solution. To get around this, you can create a service to run on the local server to forward requested ports to the remote server.
+
+To begin, I'd recommend creating two users, one on each server. For sake of example, lets all them `bridge`, though any other names like `tunnel` or whatever would work too. I'd recommend to avoid giving these users passwords, that way they can only be signed in through key based authentication. Of course you will still be able to log into them as root using `su - bridge`
+
+Next you should create an ssh keypair on the local server(`ssh-keygen`) and place the contents of your public key into `.ssh/authorized_keys`. This will make sure that only the local server will be able to ssh into the remote using that key.
+
+Then, create a script for your ssh port forwarding. I placed mine directly in the home folder of my bridge user of my local server, though it only matters that the bridge user can execute it. In your script you *must* use the `-nT` flag on your ssh command. These will allow you to run this script as a service, by preventing a virtual terminal being allocated. (read `man ssh` for more info)
+
+Here is my example of a script that you could use:
+
+ #!/bin/sh
+
+ PORTS="8080 25565"
+ DEST="bridge@remote.host"
+ SSH_PORT="22"
+ IDENTITY_FILE="~/.ssh"
+
+ /usr/bin/ssh -nNT $(echo $PORTS | awk -v host=$LOCALHOST '{for (i = 1; i <= NF; i++){ printf "-R %d:%s:%d ",$i,host,$i}}') -p $SSH_PORT -i $IDENTITY_FILE $DEST
+
+Next you'd want to run this script as a service. Check your distro's service system how to do this if you have any trouble.
+
+### Systemd service
+
+Say that the script you made was `/home/bridge/tunnel.sh`, you should create a user service with systemd for the bridge user.
+
+To do this create the following file in `/home/bridge/.config/systemd/user/tunnel.service`:
+
+ [Unit]
+ Description=SSH tunnel
+
+ [Service]
+ ExecStart=/home/bridge/tunnel.sh
+ RestartSec=5
+ Restart=always
+ KillMode=mixed
+
+ [Install]
+ WantedBy=default.target
+
+Then enable and start the service with: `systemd --user enable tunnel.service` and `system --user start tunnel.service`. Ensure that it is running with `systemd --user status tunnel`
+
+## Forwarding ports smaller than 1024
+
+As you may know, TCP/IP port numbers below 1024 are special in that normal users are not able to open, and hence forward from on the remote server. To bypass this, you can change your services to run at different ports, though this may not always be possible, for example with ports 80 and 443 for http and https respectively. One solution to this is run a server on the remote that will proxy requests from port 80 to a different port (say port 8080).
+
+This can be achieved using `socat`.
+
+Say you forwarded traffic from port 8080 on the remote to port 80 on the local, you could then, on the remote server run `sudo socat TCP-LISTEN:80,fork TCP:localhost:8080` to listen to traffic on port 80 and forward it to 8080, which will forward back to the local server. Here is an example of this in practice, forwarding port 80 and 443, by forwarding ports 8080 and 8443:
+
+ /usr/bin/ssh -nT -R 8443:localhost:443 -R 8080:localhost:80 -i $IDENTITY_FILE -p $SSH_PORT $DEST "(sudo socat TCP-LISTEN:80,fork TCP:localhost:8080) & sudo socat TCP-LISTEN:443,fork TCP:localhost:8443"
+
+However this command assumes that the remote user has access to sudo with **NO PASSWORD**. Alternatively you could create a similar service (this time as a system service) on the remote server running the socat commands.
+
+
diff --git a/html/style.css b/html/style.css
index 4221417..06f7c5d 100644
--- a/html/style.css
+++ b/html/style.css
@@ -8,6 +8,7 @@
--magenta: #b294bb;
--cyan: #b4d6d1;
--white: #c5c8c6;
+ --bg-light: #303030;
--bg: #191919;
--line: 2px;
}
@@ -20,9 +21,15 @@
body {
background-color: var(--bg);
+ background-image: url("https://davidovski.xyz/images/bg.png");
+ background-position: absolute;
+ background-repeat: no-repeat;
+ background-size: cover;
color: var(--fg);
font-family: mononoki;
- font-size: 16px
+ font-size: 16px;
+ padding: 0;
+ margin: 0;
}
a {
@@ -30,11 +37,27 @@ a {
text-decoration: none;
}
+h1 {
+ color: var(--white);
+}
+
+h2 {
+ color: var(--cyan);
+}
+
+h3 {
+ color: var(--blue);
+}
+
+
.main {
+ background-color: var(--bg);
margin-top: 0;
margin-bottom: 0;
- margin-left: 20%;
- margin-right: 20%;
+ margin-left: auto;
+ margin-right: auto;
+
+ width: 70%;
padding: 2%;
height: 100%;
@@ -60,7 +83,7 @@ hr {
border-bottom: var(--line) solid var(--fg);
}
.title {
- font-size: 40px;
+ font-size: 45px;
color: var(--fg);
}
.small {
@@ -81,3 +104,36 @@ a.blue {
color: --var(blue);
}
+code {
+ background-color: var(--bg-light);
+ font-size: 16px;
+ font-family: mononoki;
+ word-wrap: break-word;
+ width: 100%;
+}
+
+pre {
+ background-color: var(--bg-light);
+ white-space: pre-wrap;
+ padding: 5px;
+ border: var(--line) solid var(--fg);
+
+}
+
+.grid {
+ display: inline;
+}
+
+.about {
+ width: 75%;
+ float: left;
+}
+
+.image {
+ width: 25%;
+ float: right;
+}
+
+img {
+ width: 100%;
+}