Debian


Partition and Format a Disk with Ext4

Get disk information

sudo fdisk -l

Partition the disk

parted /dev/sdX mklabel gpt
parted /dev/sdX mkpart primary 0% 100%
parted /dev/sdX print
parted /dev/sdX name 1 CoolName

Format the partition

mkfs -t ext4 -E lazy_itable_init=1 /dev/sdX1

Source #1, #2

Reverse SSH Tunnel

Local

ssh -i ~/.ssh/id_rsa -f -N -R 9999:localhost:22 remote.user@remote.host

Remote

ssh -i ~/.ssh/id_rsa -p 9999 local.user@localhost

AutoSSH Local

autossh -- -i ~/.ssh/id_rsa -o ControlPath none -R 9999:localhost:22 remote.user@remote.host -N

Generate SSH Key

Generate

ssh-keygen -t rsa -b 4096

Upload

ssh-copy-id user@host

Or

cat ~/.ssh/id_rsa.pub | ssh user@host "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

See also the GitHub help page and the Digital Ocean help page.

Listing active connections

sudo netstat -taupen

Running Node.js behind Apache

Installations

Install Node.js

sudo apt-get install nodejs nodejs-legacy

Install NPM - Node Package Manager

curl https://www.npmjs.com/install.sh | sudo sh

Install PM2 - To manage and daemonize Node.js apps

sudo npm install pm2 -g

Start PM2 with the OS

sudo pm2 startup debian

Install proxy mod (might already be installed)

sudo apt-get install libapache2-mod-proxy-html

Setting up the Node.js app

Create example app

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');

Test app

node hello.js

Setup app with PM2

pm2 start hello.js

Additional PM2 commands

pm2 restart <app name>
pm2 info <app name>
pm2 stop <app name>
pm2 list
pm2 monit

Configure Apache

Activate proxy mod

sudo a2enmod proxy proxy_html
sudo service apache2 restart

Adjust virtualhost

<VirtualHost *:80>
    ServerAdmin admin@domain.tld
    ServerName domain.tld
    ServerAlias www.domain.tld
 
    ProxyRequests off
 
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
 
    <Location />
        ProxyPass http://127.0.0.1:8080/
        ProxyPassReverse http://127.0.0.1:8080/
    </Location>
</VirtualHost>

Reload apache configuration

sudo service apache2 reload