Ssh Remote Port Forwarding

2 07 2018

First of all, check in the remote host the option “GatewayPorts yes” is enabled in “/etc/sshd/sshd_config“.
That is the switch that specifies whether remote hosts are allowed to connect to ports forwarded for the client, because, by default, sshd binds remote port forwardings to the loopback address only.

An then, execute the following commando to forward a remote tcp port from a remote server to a local server:

# ssh -NR 8080:localhost:80

Test it, for example, if you have a local web server running on port :80:

# curl

More info:


Display system uptime in a website

15 06 2018

Here are the steps to set up a simple website which shows the uptime values of a system.

First of all, install the requirements. Tuptime for monitor the system, apache as web server and php for the web. The web server can be nginx as well, their only requirement is that has to be able to work with php.
apt-get install tuptime apache2 php

Go to the document root location of the webserver and download the web file from the offical repo:
cd /var/www/html/
wget -O tuptime.php

That’s all, use a web browser to open the following url and view it:

Uptime web

Python script who generates threads

5 01 2018

#!/usr/bin/env python3
import time
from threading import Thread
num_threads = 100
sleep_secs= 60
def create_thread(i):
print "Sleeping "+ str(sleep_secs) +" secs - Thread %d \n" % i
for i in range(num_threads):
t = Thread(target=create_thread, args=(i,))
print "End"

View threads in top pressing “H”
View threads in ps with “-T”

Install VMware Horizon Client in Debian 8 Jessie

24 02 2017

Download the linux client from the VMware website:

The downloaded file is a bash script, execute it from a privileged user:

# bash VMware-Horizon-Client-4.3.0-4710754.x64.bundle

Install dependencies:

# apt-get install libudev-dev libffi-dev libglibmm-2.4-dev

Before finish the install, click into the “Scan” button. If is missing and you have only (usually in a modern Debian), create a symlink for bypass:

cd /usr/lib/x86_64-linux-gnu && ln -s

Probably, if you execute now the client, it doesn’t start because the following:

$ vmware-view
/usr/lib/vmware/view/bin/vmware-view: error while loading shared libraries: cannot open shared object file: No such file or directory

Solve that creating a simlink:

# cd /lib/x86_64-linux-gnu && ln -s

And run!:

$ vmware-view

Ssh error Too many authentication failures for root

8 02 2017

ssh -o PubkeyAuthentication=no root@host

Install OpenLDAP in Debian 8

21 12 2016

This guide is the best, by far, that covers the installation of a LDAP server and the configuration of the loging of a server through it.

Split Haproxy configuration in multiple files working with Systemd

9 12 2016

Splitting Haproxy configuration in multiple files it’s a bit tricky due the Systemd startup behaviour. One workaround who works ok it’s the following:

1.- Split the Haproxy configuration file in multiple files.

1.1.- One file called “00-haproxy.conf” with the basic haproxy conf (in my case global, defaults and listen stats). This must have the 00- at the begining for listed it at first place in the script.

1.2.- One file for each listen section for the different services balanced, “some_name_a.conf”. Each new balanced service will have a new file.

Note: In this case, each balanced service is inside a listen section, not using fronted and backed.

# ls /etc/haproxy/
00-haproxy.conf service1.conf service2.conf

# cat /etc/haproxy/00-haproxy.conf
listen proxy-stats
# cat /etc/haproxy/corebalv1.conf
listen xxx
bind ...
server ...
server ...

2.- Create a small script into “/usr/local/bin/haproxy-multiconf” with this content:

for file in /etc/haproxy/*.conf; do
test -f $file
CNF="$CNF -f $file"
echo "CONF='$CNF'" > /etc/haproxy/haproxy-multiconf.lst

3.- Create a new systemd unit for create the conf list before launching the main Haproxy unit.
# cat /etc/systemd/system/haproxy-multiconf.service
Description=HAProxy Load Balancer Multiconf

4.- Modify the default systemd unit file of Haproxy:
# cat haproxy.service
Description=HAProxy Load Balancer
ExecStartPre=/usr/local/sbin/haproxy -c -q $CONF
ExecStart=/usr/local/sbin/haproxy-systemd-wrapper -p /run/ $CONF
ExecReload=/bin/kill -USR2 $MAINPID

5.- Refresh systemd and run it:

systemctl daemon-reload
systemctl restart haproxy.service