Extend or Reduce LVM in Linux
https://www.tecmint.com/extend-and-reduce-lvms-in-linux/
https://www.tecmint.com/extend-and-reduce-lvms-in-linux/
File must start with declaration code and PHP start tag:
#!/usr/bin/php <?php
File must end with PHP end tag:
?>
In the middle you can put all PHP code you want and remember that parameters are passed via the variable:
$argv[]
This is a secure solution for having a web server for many sites. With this you can specify which server user will be used for which site so apache will execute the code (mainly php) with that user preventing file system access to bad code.
On a fresh Debian 9 installation (with just SSH Server installed) let’s do:
apt-get install libapache2-mpm-itk libapache2-mod-php7.0
We’ll now enable that modules that could be useful and the one necessary:
a2enmod mpm_itk a2enmod rewrite
Now let’s configure a virtualhost:
cd /etc/apache2/sites-available touch my_website.conf nano my_website.conf
and put this inside the file (obviously you can change settings as you need):
<VirtualHost *:80>
ServerName my_website
ServerAdmin paolo@my_website
DocumentRoot /home/www/my_website/home/
<IfModule mpm_itk_module>
AssignUserId my_username my_usergroup
</IfModule>
<Directory /home/www/my_website/home/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Let’s activate my_website:
a2ensite my_website
At this point we need to create the user and the group we indicate into the file:
useradd -d /home/www/my_website -s /usr/sbin/nologin my_username
and the folders onto the path:
mkdir /home/www mkdir /home/www/my_website mkdir /home/www/my_website/home cd /home/www/my_website chown -R my_username:my_username home/
At this point we have a virtualhost that points to a folder path where apache will run scripts as my_username user.
Therefore it’s possibile to configure mysql o any other service to make this webserver richer of functions.
allow-hotplug ens192 iface ens192 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.254 dns-nameservers 192.168.21.1 192.168.11.11 192.168.31.253 dns-search mydomain.mytld
PHP file:
#!/usr/bin/php <?php echo "Hello word"; ?>
from bash command line:
chmod a+x <myfile> apt-get install php-cli ./<myfile>
Have you ever wanted to ssh to your Linux box that sits behind NAT? Now you can with reverse SSH tunneling. This document will show you step by step how to set up reverse SSH tunneling. The reverse SSH tunneling should work fine with Unix like systems.
Let’s assume that Destination’s IP is 192.168.20.83 (Linux host that you want to access).
You want to access from Linux client with IP 8.7.6.5
Destination (192.168.20.83) <- |NAT| <- Source (8.7.6.5)
ssh -R 1339:localhost:22 sourceuser@8.7.6.5
* port 1339 can be any unused port.
ssh destinationuser@localhost -p 1339
Destination (192.168.20.83) <- |NAT| <- Source (8.7.6.5) <- 3rd party server
ssh sourceuser@8.7.6.5
ssh destinationuser@localhost -p 1339
* the connection between destination and source must be alive at all time.
Tip: you may run a command (e.g. watch, top) on Destination to keep the connection active.
Strict requirement: a remote linux server with an openssh-server active daemon.
Let’s open PuTTY and start:
Now the tunnel is set up to localhost on the tcp port 1339 that you specified as source port.
Now you could setup you progrma to use a SOCKS5 proxy to use the tunnel.
Clean installation of a Debian 9.
install required packages:
– openssh-server
– libsoap-lite-perl
How to mount a physical crypted disk on another debian 9 system:
apt-get install cryptsetup apt-get install lvm2 -- lvscan lvscan vgchange -ay lvscan --help lvscan mount /dev/mapper/luks-9a9a7076-a9e3-4393-8132-bd0ee666d171 /mnt sudo fdisk -l fdisk -l udisksctl unlock -b /dev/sdb5 mount /dev/dm-0 /mnt vgchange -ay lvscan mount /dev/backup2-vg/root /mnt cd /mnt/veeam_backup/ -- fdisk -l lvscan udisksctl unlock -b /dev/sdb5 vgchange -ay mount /dev/dm-0 /mnt mount /dev/backup2-vg/root /mnt cd /mnt/veeam_backup/
How to mount a VMDK (crypted) disk on another debian 9 system:
kpartx -av .vmdk --> crea /dev/mapper/loop0p1 lvscan vgchange -ay udisksctl unlock -b /dev/mapper/loop0p5 lvscan mount /dev/backup3-vg/root /mnt ---(o il nome della partizione /root cifrata)---
This is a simple script for sending an html formatted e-mail:
$subject = "My Subject";
$headers = "From: paolo@pizzolongo.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = <<< EOT
< html >
< head >
< style >
body{background-color:#eee;margin:0;padding:0;border:0;}
h1{background-color:black;color:white;border-bottom:2px solid red;
font-size:16px; font-family:Arial;height:30px;line-height:30px;
text-indent:10px;vertical-align:middle;}
p{font-size:13px;font-family:Arial;line-height:1.2em;}
style >
head >
< body >
< h1 >Example Text< /h1 >
Hello,
this is a little text example.
Paolo's web site
regards
EOT;
mail($send_to,$subject,$message,$headers);
body >
html >