Reverse SSH tunnel shows connection to 127.0.0.1 instead of IP

Imagine the situation where you have 2 hosts:

  1. server – with public IP accessible via Internet
  2. client – with access to Internet but behind firewall so it is not accessible via Internet

You want to access client via SSH over the Internet but you can not access it because it is behind firewall that does not allow connections to the host via public IP.

My idea was to use reverse SSH tunnel started on client side, so I will be able to access client via server IP.

On your client you need to start SSH connection with something like:

ssh -f -T -N -R SERVER_IP:SERVER_PORT_TO_ACCESS_CLIENT:localhost:CLIENT_PORT_TO_ACCESS user@SERVER_PUBLIC_IP -p SERVER_SSH_PORT

If this works, you could access your client directly from server by using 127.0.0.1 since the reverse tunnel will listen only on localhost.

tcp 0 0 127.0.0.1:9999 0.0.0.0:* LISTEN

So your server is listening on localhost instead on SERVER_IP you ran on the client.

Chech your SSHd server configuration for example in file /etc/ssh/sshd_config following option should be enabled:

GatewayPorts yes

If it is not present you need to add it to your sshd_config and restart sshd.

tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN

You will be able to access your client port from any IP on server via port 9999 in this example.

 

Compile lcdproc hd44780 driver on Raspberry Pi running Debian Stretch

In order to get my 20×4 LCD display with cheap IIC/I2C/TWI/SPI Serial Interface Board running on Raspberry Pi I had to use patched hd44780.so file downloaded from NeighborGeek. You can check it out here

This worked fine on my RPi3 running Debian Jessie, but recently I have upgraded to Stretch and found out that his driver now is having issues. After running for longer period of time the screen would be full of garbage characters.

I thought I could repeat the steps, download source, patch the source, compile and use again hd44780.so file instead of the one provided by distribution.

First thing I did was to download latest source from GitHub:

wget https://github.com/lcdproc/lcdproc/archive/master.zip
unzip master.zip
cd lcdproc-master

Now I tried to apply the hd44780-i2c.c patch but it failed. Then I checked the hd44780-i2c.c file in the source I found out that patch is no longer needed just proper configuration in LCDd.conf.

In order to compile the latest driver from GitHub following steps are needed:

./autogen.sh
./configure --disable-libusb --disable-libusb-1-0 --enable-drivers=hd44780 --disable-libftdi
make

After you have compiled the driver, go to directory:

 cd /usr/lib/arm-linux-gnueabihf/lcdproc/

and backup existing file just in case something goes wrong:

cp hd44780.so hd44780.so.orig

Then copy the newly compiled driver in proper place:

cp /usr/local/src/lcdproc-master/server/drivers/hd44780.so .

Edit LCDd.conf and add the following after hd44780 part:

i2c_line_RS=0x01
i2c_line_RW=0x02
i2c_line_EN=0x04
i2c_line_BL=0x80
i2c_line_D4=0x10
i2c_line_D5=0x20
i2c_line_D6=0x40
i2c_line_D7=0x80
Backlight=yes
BacklightInvert=yes

You can download my newly compiled driver and LCDd.conf from this link  hd44780_debian_stretch.

I hope this has saved you some time and got your 20×4 LCD working with Debian Stretch.

Update

I have moved my LCD display to Pine64 SBC and since this is different architecture I needed to re-compile it using the same steps as above.

You can dowload aarch64 version hd44780.so aarch64.

Install PHP 7.1 on Debian Jessie ARM 64bit architecture

I wanted to test PHP7 on my Debian Jessie install, but latest offered package in the repositories was 5.6.30+dfsg-0+deb8u1.

In order to install PHP 7.1 which was the latest at the time of this article, you need to add following repository by running following commands:

apt-get install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update

Continue reading “Install PHP 7.1 on Debian Jessie ARM 64bit architecture”

Server side solution to stop redirect from http to https in Chrome

If you have configured your main web site domain to use SSL for example https://your.domain and https://www.your.domain and you have other sub-domains that you access without SSL you could face an issue where Chrome browser insists to use HTTPS on your sub-domains as well. This can cause problems accessing your sub-domain if it is not using SSL.

Even if you manually type http://subdomain.your.domain it will automatically redirect you to https://subdomain.your.domain Continue reading “Server side solution to stop redirect from http to https in Chrome”