Setup SSH Forward Tunneling and SSH Reverse Tunneling In The Same Line

Here’s a simple command that setups a local port tunneling via SSH and a reverse SSH Port Tunneling at the same time.

screen -dm autossh -p [22] [111.222.333.444] [-L 5555:localhost:6666] [-R 7777:localhost:22]

Put this is your rc.local file to run this on startup.

  • screen -dm creates a detached mode session other than your current one so you can have the command running after you exit the terminal
  • autossh is like SSH binary but auto reconnects if ever your connection gets terminated.
  • 22 is the SSH port, change this if you modified your server to listen on another port or your firewall does port forwarding
  • 111.222.333.444 is your target server address
  • -L 5555 is the local port number to use to forward your connection
  • localhost no explanation needed
  • 6666 the port on the other end to forward to
  • -R 7777 the port to use on the other side to connect to your home server ( your source )
  • localhost no explanation needed
  • 22 ssh port used, change this if you are listening on another port

So, if you want to connect to your source server ( home server ), all you do is connect to localhost via the port that was opened to do reverse SSH.

:> ssh [email protected] -p 7777

Ubuntu Server No Space Left on Device Error During Kernel Upgrade/Update

This error occurs when updating Ubuntu Server when the Boot partition is full…

dpkg: error processing archive [….linux-headers-x.y.z-aaa_b.c.?-???.???_all.deb] (–unpack):
unable to create ‘…linux-headers-???…’ (while processing …. ): No space left on device
No apport report written because the error message indicates a disk full error


  1. dpkg -l linux-headers-\* linux-image-\* | grep ^ii

    – This shows a list of headers and images that’s currently installed and taking up space.

  2. dpkg -P linux-headers-X.Y.Z-{a,b,c,d}{,-generic}

    – This removes all the linux-headers and linux-headers-generic packages that has the version of X.Y.Z and all of the version numbers within the { }

  3. dpkg -P linux-image-extra-X.Y.Z-{a,b,c,d}-generic

    – This does the same but with linux-image-extra

  4. dpkg -P linux-image-X.Y.Z-{a,b,c,d}-generic

    – This does the same but with linux-image

  5. apt-get -f install

    – This will reinstall the update/upgrade packages that failed.

Show / Reveal Files and Folders From an Infected Flash Drive

Flash drives are very susceptible to worms/”virus” infection.
One behavior is hiding your files/folders in a blank folder name and set it to system attribute.
Then add a shortcut to open that hidden folder and also infect your system.


Now, to recover the files…

Revealing hidden files and folders from an infected flash drive, use the command below.

attrib *.* -h -s -r /s /d

This will now show the folders and files, rename the _blank_ folder to your preferred name and recover your files. =)

MariaDB 10.2 – Field ‘xxxxxxx’ doesn’t have a default value Error

I update one of my production server MariaDB 10.1 database server to 10.2 thinking everything will be ok, I did a live test in one of my VM machines and everything went smoothly…. well… on the outside that is.
As I finished updating the server, I started getting java.sql.SQLException: Field ‘xxxxxx’ doesn’t have a default value in my logs.
This didn’t happen before.
I soon found out from MariaDB document page….

Since MariaDB 10.2.4, SQL_MODE is by default set to NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO. In earlier versions of MariaDB 10.2, and since MariaDB 10.1.7, SQL_MODE is by default set to NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER. For earlier versions of MariaDB 10.1, and MariaDB 10.0 and before, no default is set.

So, this means that as soon as I updated my server to MariaDB 10.2, my sql_mode was set to “strict” mode by default internally.

The work around(?)/fix…go to the MariaDB config file (my.cnf) and change the sql_mode line to

sql_mode                = NO_ENGINE_SUBSTITUTION

Hope this helps those who ran into this problem.
(Note: Another fix is to manually set all table fields to have a default value – too long, too tiresome, Also you can change your code to set all default values – also too long and tiresome )

Link to other sources:

PFSense wkhtmltopdf WebApp NAT Loopback/Reflection Woes

Please DO NOT use public IP address when generating your pdf using wkhtmltopdf/wkhtmltojpg if you have PFSense running as a firewall.

Use localhost, this will save you headaches.

I’m using WKHTMLTOPDF to convert html to pdf and inside the html contains links to images. Now the address used is the public IP address but wkhtmltopdf is running internally in the local network with its ‘web browser’. See the problem here? Normally, routers allow NAT Reflection/Loopbank… PFSense blocks this by default. So my images were not rendering, for which leaves the wkhtmltopdf process to lag behind due to it waiting for a reply from the server which PFSense is denying, timeout it around 60 sec ( 1 Min ).

Setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3

Here, I was able to setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3.



  1. Install/Burn Raspbian to your microsd card. Instructions here.
  2. After burning/installing the image to your SD card. Install it to your Raspberry PI and configure it so you can SSH into it properly. Sadly, SSH daemon is not automatically configured to start on boot.
  3. To Enable SSH to autostart on boot… do
  4. :> update-rc.d ssh defaults
    :> update-rc.d ssh enable
  5. Restart and try to login remotely
  6. If you can not login, sshd may be configured to deny any remote root connection
  7. Got to /etc/ssh/ and edit sshd_config
  8. Look for this line…
  9. PermitRootLogin.......
  10. And change it to…
  11. PermitRootLogin yes

    Continue Reading

JPMorgan Quorum Cakeshop Setup Ubuntu 16.04.2

I wanted to study JPMorgan’s Quorum Blockchain and going to install Cakeshop, their development environment, under Ubuntu 16.04.2 and Tomcat8 web server.
There were some bumps that were unavoidable but the developer was very helpful in debugging and help me setup the server. Shout out to fixanoid

  • Install Ubuntu 16.04.2
  • Update to latest updates
  • Install Java 8 (Open JDK)
  • Install Tomcat8
  • Follow the installation instruction here… BUT don’t start the server yet.
  • Instead of, edit Tomcat8 startup script under /etc/init.d/ folder.
  • Under catalina_sh() function, go to TOMCAT_SH= line
  • Before that, add this command…. JAVA_OPTS=”$JAVA_OPTS -Deth.config.dir=[Your/folder/path/accessible/to/tomcat8/user]”
  • Start the server /etc/init.d/tomcat start, then stop it /etc/init.d/tomcat8 stop
  • The server will not yet run peroperly and error logs will populate catalina.out logs, but this will populate config files int the folder you passed in JAVA_OPTS (eth.config.dir=[Your/folder/path/accessible/to/tomcat8/user])
  • No go to the folder, under the local folder, edit
  • Locate geth.identity=
  • Add any node name you want it to be
  • Save the file, exit and start the server again
  • This should start the server properly now. You check the catalina.out logs.
  • You can access the site via http://IP_ADDRESS:8080/cakeshop/

MariaDB Unknown/unsupported storage engine: InnoDB

I had this problem re-occurring in one of my servers. MariaDB wont start due to this error.

To fix my problem, remove these log files…


ib_logfile may be 0 or 1

If you want to be safe.. just rename it to another file temporarily to see if it works.

Sources for the fix can be found Here and Here

Ubuntu 16.04.02 Hang on Reboot or Shutdown

Had a problem after an update that when I force a restart or a shutdown on my server, it hangs on the last part of the process.

To fix my problem, I had to edit the /etc/default/grub config file and added acpi=force apm=power_off to the config line, between the double quotation marks…




do a update-grub after saving then reboot one more time.. ( force sa restart when it hangs )
After the restart, try another reboot, it should work now without hanging.

Source of the fix is from Here

Heap Dump and Remote Tomcat 8-OpenJDK 8 Memory Monitoring

Memory problem.. the thorn of web apps… I have to connect to my remote server to monitor its memory usage and produce a heap dump.
Bellow is the steps I had to configure the server to allow me to connect a remote monitor tool.

Requirement: VisualVM app, download here

  1. Access your file.
  2. Look for JAVA_OPTS, if none found, you can add your own.
  3. Add …
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/

    to the line if found, if not, you can do

    JAVA_OPTS="JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/"

    The above code will force a heamp dump when the server encounter a out-of-mem exception.

  4. Next, to enable remote memory monitoring, add these commands after the line above, within the quotation mark, add proper spacing after each command…
  5. Now, run VisualVM and create a new JMX remote connection, under the CONNECTION field, add host_ip_address:port_num

Congrats! You should now be able to connect to your server and monitor your memory usage!