Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 72
» Latest member: stewartshic
» Forum threads: 342
» Forum posts: 369

Full Statistics

Online Users
There are currently 9 online users.
» 0 Member(s) | 9 Guest(s)

Latest Threads
Test, just a XRumer 23 St...
Forum: Announcements
Last Post: XRumer23lip
09-25-2025, 01:01 AM
» Replies: 0
» Views: 30
Comment créer un sous-dom...
Forum: Cpanel
Last Post: XRumer23lip
10-28-2024, 04:29 AM
» Replies: 1
» Views: 1,189
Tutorial: Create an Onlin...
Forum: Ellohost
Last Post: mikox
08-03-2024, 07:46 AM
» Replies: 0
» Views: 288
Tutoriel : Créer un Site ...
Forum: Ellohost
Last Post: mikox
08-03-2024, 07:45 AM
» Replies: 0
» Views: 314
Tutorial: Create a Profes...
Forum: Ellohost
Last Post: mikox
08-03-2024, 07:13 AM
» Replies: 0
» Views: 220
Tutoriel : Créer un Site ...
Forum: Ellohost
Last Post: mikox
08-03-2024, 07:12 AM
» Replies: 0
» Views: 252
Slither.io - Become the L...
Forum: Others
Last Post: mikox
04-05-2024, 07:30 AM
» Replies: 0
» Views: 310
MooMoo.io - Build, Defend...
Forum: Others
Last Post: mikox
04-05-2024, 07:28 AM
» Replies: 0
» Views: 332
Smash Karts - The Ultimat...
Forum: Others
Last Post: mikox
04-05-2024, 07:26 AM
» Replies: 0
» Views: 712
Dream Chef - A Cooking Ad...
Forum: Others
Last Post: mikox
04-05-2024, 07:24 AM
» Replies: 0
» Views: 305

 
  How to Manage Domains and Emails in Plesk
Posted by: aaron - 07-22-2023, 10:00 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>Managing Domains and Emails in Plesk</title>
</head>
<body>
    <h2>Add a New Domain in Plesk:</h2>
    <p>After setting up a Plesk server, follow these steps to add a new domain:</p>
    <ol>
        <li>On the sidebar, click <strong>Websites &amp; Domain</strong>.</li>
        <li>Click <strong>Add domain</strong> → <strong>Blank website</strong>.</li>
        <li>Enter the required information, like your domain name and webspace settings. Click <strong>Add Domain</strong> to confirm.</li>
    </ol>
Plesk will show your new domain’s configuration menu. Click <strong>Hosting &amp; DNS</strong> → <strong>DNS</strong>.
Point your domain to your VPS hosting using the information in the Records tab. Your domain should be accessible within 24 hours after the DNS propagation process is completed.
Managing multiple domains is simple since users can configure them on a single screen. Click the domain name to manage its SSH access, security features, and domain-based email account.

<h3>Create a New Email Account:</h3>
To create a new email account, click the <strong>Mail</strong> tab → <strong>Mail Accounts</strong> → <strong>Create Email Address</strong>. Enter your desired local part, set a new password, and click <strong>Ok</strong> to finish the process.
<img src="https://ellohost.com/imageshack/uploads/1690019947_64bba86bc820a.jpeg" width="50%" alt="Email Account Creation Screenshot">
You can also change the mail settings from the same menu, like enabling the service and applying Secure Sockets Layer (SSL) certificates. To create emails for other domain names, navigate to <strong>Mail</strong> on the sidebar.

    <br><br>
    <a href="https://ellohost.com">
        <button style="padding: 10px 20px; background-color: blue;">Join ellohost</button>
    </a>
</body>
</html>

Print this item

  Comment installer Fail2Ban
Posted by: aaron - 07-22-2023, 09:55 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>Comment installer Fail2Ban</title>
</head>
<body>
    <h2>Installer Fail2Ban sur Ubuntu :</h2>
    <p>Avant d'installer un nouveau paquet, nous vous recommandons de mettre à jour le référentiel et le logiciel du système. Exécutez la commande suivante :</p>
    <pre><code>apt-get update && apt-get upgrade</code></pre>
    <p>Installez le paquet Fail2Ban en exécutant la commande ci-dessous :</p>
    <pre><code>apt-get install fail2ban</code></pre>
    <p>Si vous souhaitez ajouter le support de messagerie électronique pour le service Fail2Ban, insérez la commande suivante et appuyez sur Entrée :</p>
    <pre><code>apt-get install sendmail</code></pre>
    <p>Vérifiez l'état de Fail2Ban en utilisant la commande suivante :</p>
    <pre><code>sudo systemctl status fail2ban</code></pre>

    <h2>Installer Fail2Ban sur CentOS :</h2>
    <p>Fail2Ban pour CentOS7 est inclus dans le référentiel Extra Packages for Enterprise Linux (EPEL). Téléchargez-le en exécutant la commande suivante :</p>
    <pre><code>sudo yum install epel-release</code></pre>
    <p>Une fois cela fait, installez Fail2Ban en entrant la commande suivante et en appuyant sur Entrée :</p>
    <pre><code>sudo yum install fail2ban</code></pre>
    <p>Activez et démarrez le service en utilisant ces commandes :</p>
    <pre><code>sudo systemctl enable fail2ban</code></pre>
    <pre><code>sudo systemctl start fail2ban</code></pre>

    <h2>Installer Fail2Ban sur Debian :</h2>
    <p>Mettez à jour le référentiel et effectuez la mise à niveau de votre système en saisissant la commande ci-dessous et en appuyant sur Entrée :</p>
    <pre><code>apt-get update && apt-get upgrade -y</code></pre>
    <p>Poursuivez l'installation de Fail2Ban en utilisant la commande suivante :</p>
    <pre><code>apt-get install fail2ban</code></pre>
    <p>Si vous souhaitez ajouter le support de messagerie électronique, installez Sendmail en exécutant cette commande :</p>
    <pre><code>apt-get install sendmail-bin sendmail</code></pre>
    <p>Vérifiez l'état de Fail2Ban :</p>
    <pre><code>systemctl status fail2ban</code></pre>

    <h2>Installer Fail2Ban sur Fedora :</h2>
    <p>Mettez à jour le référentiel de votre système en utilisant la commande ci-dessous et en appuyant sur Entrée :</p>
    <pre><code>dnf update</code></pre>
    <p>Installez Fail2Ban en utilisant cette commande :</p>
    <pre><code>dnf install fail2ban</code></pre>
    <p>Si vous souhaitez installer Sendmail, tapez la commande suivante et appuyez sur Entrée :</p>
    <pre><code>dnf install sendmail</code></pre>
    <p>Démarrez et activez le service Fail2Ban en utilisant les commandes suivantes :</p>
    <pre><code>systemctl start fail2ban</code></pre>
    <pre><code>systemctl enable fail2ban</code></pre>
    <p>Si vous avez ajouté Sendmail, exécutez les commandes suivantes pour le démarrer et l'activer :</p>
    <pre><code>systemctl start sendmail</code></pre>
    <pre><code>systemctl enable sendmail</code></pre>

    <br><br>
    <a href="https://ellohost.com">
        <button style="padding: 10px 20px; background-color: blue;">Rejoindre ellohost</button>
    </a>
</body>
</html>

Print this item

  How to Install Fail2Ban
Posted by: aaron - 07-22-2023, 09:54 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>How to Install Fail2Ban</title>
</head>
<body>
    <h2>Install Fail2Ban on Ubuntu:</h2>
    <p>Before installing a new package, we recommend updating the system repository and software. Run the following command:</p>
    <pre><code>apt-get update &amp;&amp; apt-get upgrade</code></pre>
    <p>Install the Fail2Ban package by running the command below:</p>
    <pre><code>apt-get install fail2ban</code></pre>
    <p>If you want to add email support for the Fail2Ban service, insert the following command and press Enter:</p>
    <pre><code>apt-get install sendmail</code></pre>
    <p>Verify Fail2Ban status using the following command:</p>
    <pre><code>sudo systemctl status fail2ban</code></pre>

    <h2>Install Fail2Ban on CentOS:</h2>
    <p>Fail2Ban for CentOS7 is included in the Extra Packages for Enterprise Linux (EPEL) repository. Download it by running the command below:</p>
    <pre><code>sudo yum install epel-release</code></pre>
    <p>Once that is done, install Fail2Ban by inputting the following command and pressing Enter:</p>
    <pre><code>sudo yum install fail2ban</code></pre>
    <p>Enable and start the service by running these commands:</p>
    <pre><code>sudo systemctl enable fail2ban</code></pre>
    <pre><code>sudo systemctl start fail2ban</code></pre>

    <h2>Install Fail2Ban on Debian:</h2>
    <p>Update and upgrade your system repository by typing in the command below and pressing Enter:</p>
    <pre><code>apt-get update &amp;&amp; apt-get upgrade -y</code></pre>
    <p>Proceed with the Fail2Ban installation using the following command:</p>
    <pre><code>apt-get install fail2ban</code></pre>
    <p>If you want to add email support, install Sendmail by running this command:</p>
    <pre><code>apt-get install sendmail-bin sendmail</code></pre>
    <p>Check Fail2Ban's status:</p>
    <pre><code>systemctl status fail2ban</code></pre>

    <h2>Install Fail2Ban on Fedora:</h2>
    <p>Update your system repository by inserting the command below and pressing Enter:</p>
    <pre><code>dnf update</code></pre>
    <p>Install Fail2Ban using this command:</p>
    <pre><code>dnf install fail2ban</code></pre>
    <p>If you want to install Sendmail, type in the following command and press Enter:</p>
    <pre><code>dnf install sendmail</code></pre>
    <p>Start and enable the Fail2Ban service by running the following commands:</p>
    <pre><code>systemctl start fail2ban</code></pre>
    <pre><code>systemctl enable fail2ban</code></pre>
    <p>If you've added Sendmail, run the following to start and enable it:</p>
    <pre><code>systemctl start sendmail</code></pre>
    <pre><code>systemctl enable sendmail</code></pre>

    <br><br>
    <a href="https://ellohost.com">
        <button style="padding: 10px 20px; background-color: blue;">Join ellohost</button>
    </a>
</body>
</html>

Print this item

  Comment Sécuriser Votre Serveur Linux avec la Configuration Fail2Ban
Posted by: aaron - 07-22-2023, 05:23 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>Comment Sécuriser Votre Serveur Linux avec la Configuration Fail2Ban</title>
</head>
<body>
<h1>Comment Configurer Fail2Ban</h1>
<p>Après avoir installé Fail2Ban, envisagez de le configurer. Dans cette section, nous allons voir comment le faire à l'aide des fichiers fail2ban.local et jail.local.</p>

<h2>Modifier les Paramètres par Défaut avec fail2ban.local (Optionnel)</h2>
<p>Le fichier fail2ban.conf contient la configuration de base de Fail2Ban. Il contient les paramètres globaux qui ne doivent pas être modifiés.</p>
<p>Si vous souhaitez apporter des modifications, nous vous recommandons de créer un fichier local. Faites une copie de fail2ban.conf et renommez-le en fail2ban.local pour remplacer le profil de configuration par défaut.</p>
<p>Voici comment renommer la copie et configurer les paramètres dans le fichier fail2ban.local :</p>
<pre><code>cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local</code></pre>
<p>Tapez la commande suivante et appuyez sur Entrée pour ouvrir le fichier :</p>
<pre><code>sudo nano /etc/fail2ban/fail2ban.local</code></pre>
<p>Vous pouvez maintenant modifier les définitions à l'intérieur du fichier. Examinons les options et les valeurs possibles.</p>

<p><strong>loglevel = INFO</strong></p>
<p>Définit le niveau de sortie des journaux :</p>
<ul>
    <li>CRITICAL – conditions d'urgence qui doivent être immédiatement examinées.</li>
    <li>ERROR – quelque chose ne va pas, mais ce n'est pas critique.</li>
    <li>WARNING – une condition potentiellement nuisible.</li>
    <li>NOTICE – une condition normale mais significative.</li>
    <li>INFO – messages informatifs qui peuvent être ignorés.</li>
    <li>DEBUG – messages de débogage.</li>
</ul>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09e31.jpeg" width="50%" alt="loglevel">

<p><strong>logtarget = STDERR</strong></p>
<p>Enregistre les actions dans une cible de journal spécifique, qui peut être :</p>
<ul>
    <li>FILE – enregistrement dans un fichier journal.</li>
    <li>SYSLOG – enregistrement dans un fichier journal basé sur les messages.</li>
    <li>STDERR – enregistrement dans une sortie standard d'erreur.</li>
    <li>STDOUT – sortie standard.</li>
</ul>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09f0d.jpeg" width="50%" alt="logtarget">

<p><strong>syslogsocket = auto</strong></p>
<p>Définit le fichier de socket du journal système sur auto ou file (si vous avez défini logtarget en SYSLOG).</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09fc6.jpeg" width="50%" alt="syslogsocket">

<p><strong>socket = /var/run/fail2ban/fail2ban.sock</strong></p>
<p>Définit le fichier de socket pour communiquer avec le démon. L'emplacement par défaut est /var/run/fail2ban/fail2ban.sock.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09fc6.jpeg" width="50%" alt="socket">

<p><strong>pidfile = /var/run/fail2ban/fail2ban.pid</strong></p>
<p>Définit le fichier PID pour stocker l'identifiant de processus du serveur Fail2Ban. L'emplacement par défaut est /var/run/fail2ban/fail2ban.pid.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a04b.jpeg" width="50%" alt="pidfile">

<h2>Configuration du Fichier jail.local</h2>
<p>Fail2Ban possède un autre fichier de configuration nommé jail.conf qui inclut les « jails » - des filtres avec des actions. Cependant, les utilisateurs ne doivent pas modifier directement ce fichier car il contient l'ensemble de règles de base du logiciel.</p>
<p>Au lieu de cela, faites une copie du fichier original et renommez-le jail.local. En l'utilisant, vous pourrez personnaliser et configurer les filtres et les actions, tels que ignoreip, bantime, findtime, maxretry et backend.</p>

<p><strong>ignoreip</strong></p>
<p>Cette fonctionnalité vous permet de spécifier des adresses IP, des hôtes DNS ou des masques CIDR de confiance que Fail2Ban doit ignorer. Ce paramètre autorise tout le trafic provenant des sources spécifiées. Vous pouvez ajouter plusieurs adresses en les séparant par un espace.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a0ea.jpeg" width="50%" alt="ignoreip">

<p><strong>bantime</strong></p>
<p>Ce paramètre définit la durée pendant laquelle un client sera banni après des tentatives d'authentification infructueuses. La période de bannissement est mesurée en secondes, et la valeur par défaut est de 600 secondes (soit 10 minutes).</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a168.jpeg" width="50%" alt="bantime">

<p><strong>findtime</strong></p>
<p>Ce paramètre détermine la période pendant laquelle des tentatives de connexion infructueuses peuvent se produire. Si un hôte échoue un certain nombre de fois (selon le paramètre maxretry) pendant la période définie, son adresse IP sera bannie.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a1e3.jpeg" width="50%" alt="findtime">

<p><strong>maxretry</strong></p>
<p>maxretry fonctionne conjointement avec findtime - il définit le nombre maximum de tentatives de connexion infructueuses autorisées pendant la fenêtre de temps définie. La valeur par défaut est de 5.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a24a.jpeg" width="50%" alt="maxretry">

<p><strong>backend</strong></p>
<p>Cette fonctionnalité vous permet de spécifier la configuration backend pour la modification de fichiers. La valeur par défaut est auto, mais si vous utilisez CentOS ou Fedora, elle doit être systemd.</p>
<p>Voici les valeurs disponibles parmi lesquelles vous pouvez choisir :</p>
<ul>
    <li>pynotify - surveille les modifications du système de fichiers en temps réel et nécessite l'installation d'un moniteur d'altération de fichiers.</li>
    <li>gamin - identique à pynotify mais nécessite l'outil Gamin.</li>
    <li>polling - utilise un algorithme de sondage qui ne nécessite pas de bibliothèques externes.</li>
    <li>systemd - utilise la bibliothèque Python de systemd pour accéder au journal de systemd.</li>
    <li>auto - utilisera les valeurs précédentes dans cet ordre - pyinotify, gamin et polling.</li>
</ul>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a2aa.jpeg" width="50%" alt="backend">

<p>Vous pouvez également configurer des paramètres supplémentaires dans le fichier jail.local, y compris les paramètres SSH et iptables. Les options disponibles incluent :</p>
<ul>
    <li>banaction - définit quelle action par défaut utiliser lorsque le seuil maxretry est atteint. Si vous utilisez firewalld, définissez la valeur sur firewallcmd-ipset. Cependant, si vous avez configuré UFW comme pare-feu, changez-la en ufw.</li>
    <li>banaction_allports - vous permet d'étiqueter et de bloquer les adresses IP sur tous les ports. Si vous utilisez firewalld, définissez la valeur sur firewallcmd-ipset.</li>
    <li>port - la valeur doit correspondre au service défini. Si vous utilisez le port par défaut, changez la valeur en nom du service. Si vous utilisez un port non traditionnel, entrez son numéro ici.</li>
    <li>filter - le nom du fichier situé dans /etc/fail2ban/filter.d contient les informations failregex utilisées pour analyser les fichiers journaux.</li>
</ul>

<p><a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Rejoignez ellohost</button></a></p>

</body>
</html>

Print this item

  How to Secure Your Linux Server with Fail2Ban Configuration
Posted by: aaron - 07-22-2023, 05:22 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>How to Secure Your Linux Server with Fail2Ban Configuration</title>
</head>
<body>
<h1>How to Set Up Fail2Ban</h1>
<p>After installing Fail2Ban, consider configuring it. In this section, we will explore how to do it using the fail2ban.local and jail.local files.</p>

<h2>Edit the Default Settings with fail2ban.local (Optional)</h2>
<p>The fail2ban.conf file houses Fail2Ban’s basic configuration. It contains the global settings that should not be modified.</p>
<p>If you want to make any changes, we recommend creating a local file. Make a copy of fail2ban.conf and rename it to fail2ban.local to override the default configuration profile.</p>
<p>Here’s how to change the name of the copy and setup the settings on fail2ban.local file:</p>
<pre><code>cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local</code></pre>
<p>Type in the following command and press Enter to open the file:</p>
<pre><code>sudo nano /etc/fail2ban/fail2ban.local</code></pre>
<p>Now you can edit the definitions inside the file. Let’s go over the options and the values they can take.</p>

<p><strong>loglevel = INFO</strong></p>
<p>Define the log output level as:</p>
<ul>
    <li>CRITICAL – emergency conditions that should be investigated immediately.</li>
    <li>ERROR – something goes wrong but is not critical.</li>
    <li>WARNING – a potentially harmful condition.</li>
    <li>NOTICE – a normal but significant condition.</li>
    <li>INFO – informational messages that can be ignored.</li>
    <li>DEBUG – debug-level messages.</li>
</ul>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09e31.jpeg" width="50%" alt="loglevel">

<p><strong>logtarget = STDERR</strong></p>
<p>Log actions in a specific target socket, which can be:</p>
<ul>
    <li>FILE – output to a file socket.</li>
    <li>SYSLOG – output to a message-based log file.</li>
    <li>STDERR – output as a standard error.</li>
    <li>STDOUT – standard output.</li>
</ul>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09f0d.jpeg" width="50%" alt="logtarget">

<p><strong>syslogsocket = auto</strong></p>
<p>Set the syslog socket file to auto or file (if you’ve set logtarget as SYSLOG).</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09fc6.jpeg" width="50%" alt="syslogsocket">

<p><strong>socket = /var/run/fail2ban/fail2ban.sock</strong></p>
<p>Set the socket file to communicate with the daemon. The default location is /var/run/fail2ban/fail2ban.sock.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce09fc6.jpeg" width="50%" alt="socket">

<p><strong>pidfile = /var/run/fail2ban/fail2ban.pid</strong></p>
<p>Set the PID file to store the process ID of the Fail2Ban server. The default location is /var/run/fail2ban/fail2ban.pid.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a04b.jpeg" width="50%" alt="pidfile">

<h2>Setting Up the jail.local Configuration File</h2>
<p>Fail2Ban has another configuration file named jail.conf which includes jails – filters with actions. However, users shouldn’t directly modify this file as it contains the basic rule set for the software.</p>
<p>Instead, make a copy of the original file and name it jail.local. Using it, you’ll be able to customize and setup filters and actions, such as ignoreip, bantime, findtime, maxretry, and backend.</p>

<p><strong>ignoreip</strong></p>
<p>This feature requires you to specify trusted IP addresses, DNS hosts, or CIDR masks that Fail2Ban should ignore. This parameter permits all traffic coming from the specified sources. You can add multiple addresses and separate them with a space.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a0ea.jpeg" width="50%" alt="ignoreip">

<p><strong>bantime</strong></p>
<p>This parameter sets the length of time that a client will be banned for after failed authentication. The ban period is measured in seconds, and the default number is 600 or 10 minutes.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a168.jpeg" width="50%" alt="bantime">

<p><strong>findtime</strong></p>
<p>This setting determines the time period for failed login attempts. If a host fails authentication a certain number of times (based on the maxretry setting) during the set period, its IP address will be banned.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a1e3.jpeg" width="50%" alt="findtime">

<p><strong>maxretry</strong></p>
<p>maxretry works together with findtime – it sets the maximum number of unsuccessful login attempts within the defined time window. The default value is 5.</p>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a24a.jpeg" width="50%" alt="maxretry">

<p><strong>backend</strong></p>
<p>This feature allows you to specify the backend configuration for file modification. The default value is auto, but if you use CentOS or Fedora, it needs to be systemd.</p>
<p>Here are the available values you can choose from:</p>
<ul>
    <li>pynotify – monitors file system changes in real time and requires a file alteration monitor to be installed.</li>
    <li>gamin – same as pynotify but requires a Gamin tool.</li>
    <li>polling – uses a polling algorithm that doesn’t require external libraries.</li>
    <li>systemd – uses the systemd python library to access the systemd journal.</li>
    <li>auto – will use the previous values in this order – pyinotify, gamin, and polling.</li>
</ul>
<img src="https://ellohost.com/imageshack/uploads/1690003150_64bb66ce0a2aa.jpeg" width="50%" alt="backend">

<p>You can also setup additional configurations in the jail.local file, including SSH and iptables settings. The available options include:</p>
<ul>
    <li>banaction – defines which default action to use when the maxretry threshold is reached. If you use firewalld, set the value to firewallcmd-ipset. However, if you’ve set up UFW as your firewall, change it to ufw.</li>
    <li>banaction_allports – allows you to label and block IP addresses on every port. If you use firewalld, set the value to firewallcmd-ipset.</li>
    <li>port – the value should correspond to the set service. If you use the default port, change the value to the service name. If you use a non-traditional port, input its number here.</li>
    <li>filter – the file name located in /etc/fail2ban/filter.d contains the failregex information used to parse log files.</li>
</ul>

<p><a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Join ellohost</button></a></p>

</body>
</html>

Print this item

  Comment Utiliser les Tableaux en Bash
Posted by: aaron - 07-22-2023, 05:13 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>Comment Utiliser les Tableaux en Bash</title>
</head>
<body>
<h2>Qu'est-ce qu'un Tableau en Bash ?</h2>

    Un tableau en bash est une structure de données conçue pour stocker des informations de manière indexée. En d'autres termes, un tableau en bash est un groupe important de variables. Contrairement aux tableaux typiques utilisés dans d'autres langages de programmation, les tableaux en bash peuvent stocker différents types d'éléments. Par exemple, vous pouvez utiliser un tableau en bash pour stocker à la fois des chaînes de caractères et des nombres.


Il existe deux types de tableaux en bash :
<ul>
    <li>Indexé - le tableau est référencé via des entiers ou des nombres.</li>
    <li>Associatif - le tableau est référencé via des chaînes de caractères ou un ensemble de caractères et de mots.</li>
</ul>


    Rappelez-vous que bash ne prend pas en charge les tableaux multidimensionnels, il n'est donc pas possible d'ajouter un tableau dans un tableau.


<h3>Comment Déclarer un Tableau en Bash</h3>

    Il y a plusieurs façons de déclarer des tableaux indexés et associatifs en bash. Il est bon de noter que la taille du tableau bash n'a pas besoin d'être déclarée au préalable car les tableaux en bash n'ont pas de limite supérieure sur le nombre d'éléments qu'ils peuvent stocker.


<h4>Tableau Indexé</h4>

    Nous commencerons par un simple tableau indexé en bash. Par exemple, nous l'utiliserons pour créer une liste de différents moyens de transport.

<code><code>
declare -a TableauIndexe
TableauIndexe[0]=voiture
TableauIndexe[1]=avion
TableauIndexe[2]=vélo
</code></code>

    La même chose peut être réalisée sans le mot-clé <code>declare</code> :

<code><code>
TableauIndexe[0]=voiture
TableauIndexe[1]=avion
TableauIndexe[2]=vélo
</code></code>

    Ou, encore plus simple :

<code><code>
TableauIndexe=(voiture avion vélo)
</code></code>

    Rappelez-vous que l'indexation commence à 0, donc l'exemple ci-dessus attribuera l'élément voiture du tableau à l'indice 0.



    Cependant, il est possible de définir un tableau avec des indices :

<code><code>
TableauIndexe=([0]='voiture' [1]='avion' [2]='vélo')
</code></code>

    Une caractéristique intéressante des tableaux en bash est que suivre les numéros d'index dans l'ordre n'est pas nécessaire. Par exemple, vous pouvez déclarer uniquement le premier et le troisième élément tout en laissant le deuxième élément d'un tableau vide :

<code><code>
TableauIndexe[0]=voiture
TableauIndexe[2]=vélo
</code></code>

<h4>Tableau Associatif</h4>

    Alors que les tableaux indexés ne nécessitent pas le mot-clé <code>declare</code>, il ne sera pas possible de créer un tableau associatif en bash sans le déclarer au préalable :

<code><code>
declare -A TableauAssociatif
</code></code>

    Ensuite, ajoutez les valeurs. Gardez à l'esprit que la clé doit être une chaîne de caractères :

<code><code>
TableauAssociatif[couleur]=bleu
TableauAssociatif[type]=voiture
TableauAssociatif[vitesse_max]=200
</code></code>

    Une autre façon serait :

<code><code>
declare -A TableauAssociatif=( [couleur]=bleu [type]=voiture [vitesse_max]=200 )
</code></code>

<h3>Comment Ajouter une Variable à un Tableau en Bash</h3>

    Ajoutez facilement des variables en utilisant l'opérateur <code>+=</code>. Par exemple, le processus pour un tableau indexé ressemblerait à ceci :

<code><code>
TableauIndexe=(voiture avion vélo)
TableauIndexe+=(moto)
</code></code>

    Le tableau indexé a maintenant un nouvel élément. Rappelez-vous que cette méthode ajoute à la fin du tableau. Par conséquent, l'élément moto sera ajouté en tant que dernier élément.



    Pour les tableaux associatifs, le processus est très similaire. Sauf que vous devez spécifier les clés avec tous les éléments :

<code><code>
declare -A TableauAssociatif
TableauAssociatif[couleur]=bleu
TableauAssociatif+=( [roues]=alliage [moteur]=essence )
</code></code>

<h3>Comment Référencer et Afficher un Élément du Tableau</h3>

    Les utilisateurs peuvent référencer les valeurs du tableau bash en utilisant l'index de l'élément ou la clé. Pour cela, créez un tableau indexé :

<code><code>
TableauIndexe=(voiture avion vélo)
</code></code>

    Pour référencer la première variable du tableau, utilisez la syntaxe suivante :

<code><code>
${TableauIndexe[0]}
</code></code>

    Combinez-le avec <code>echo</code>, et vous obtiendrez ceci :

<code><code>
echo ${TableauIndexe[0]}
</code></code>

    La sortie vous montrera le premier élément. Dans ce cas, c'est voiture. La même logique s'applique lors de la référence et de l'affichage d'un tableau associatif :

<code><code>
declare -A TableauAssociatif=( [couleur]=bleu [type]=voiture [vitesse_max]=200 )
echo ${TableauAssociatif[type]}
</code></code>

    La sortie sera également voiture.


    Pour afficher tout le tableau, utilisez <code>@</code> comme index. Le script complet ressemble à ceci :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bc8f.jpeg" alt="Exemple de Tableau Indexé" width="50%">

    Vous pouvez également afficher les clés d'un tableau. Pour ce faire, ajoutez un point d'exclamation avant le nom du tableau :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bbaa.jpeg" alt="Exemple de Tableau Associatif" width="50%">

<h3>Comment Supprimer des Éléments d'un Tableau en Bash</h3>

    Supprimer des éléments de tableau est similaire à leur référencement. Utilisez un index ou une clé combiné avec la commande <code>unset</code> pour supprimer un élément de tableau.


    Voici un exemple de suppression d'un seul élément d'un tableau indexé :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bb42.jpeg" alt="Supprimer un Élément de Tableau Indexé" width="50%">

    Une logique similaire s'applique aux tableaux associatifs :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bad6.jpeg" alt="Supprimer un Élément de Tableau Associatif" width="50%">

    Pour supprimer un tableau entier, spécifiez <code>unset</code> avec le nom du tableau comme indiqué ici :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b96a.jpeg" alt="Supprimer un Tableau Entier" width="50%">

    Rien n'est affiché après avoir essayé d'imprimer les éléments du tableau car la commande <code>unset</code> les a supprimés.


<h3>Comment Parcourir un Tableau en Boucle</h3>

    La création de boucles en bash est un aspect fondamental de l'apprentissage des bases du scripting en bash. Vous pouvez également utiliser des boucles avec des tableaux. Par exemple, le cas d'utilisation le plus courant est d'itérer sur chaque élément du tableau :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b8f1.jpeg" alt="Parcourir un Tableau en Boucle" width="50%">

    Vous pouvez également combiner les clés avec les éléments du tableau et les afficher tous ensemble comme ceci :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b7c7.jpeg" alt="Parcourir un Tableau Associatif en Boucle" width="50%">

<h3>Comment Passer un Tableau à une Fonction</h3>

    Les fonctions vous font gagner beaucoup de temps lors du scripting. Au lieu d'écrire le même code à plusieurs reprises, vous pouvez appeler une fonction déjà écrite. Nous allons combiner la boucle d'itération précédemment mentionnée et en faire une fonction :

<code><code>
function Iteration
{
m=${#TableauIndexe[@]}
for (( i=0; i<m; i++ ))
do
echo ${TableauIndexe[$i]}
done
}
TableauIndexe=(voiture vélo avion)
Iteration ${TableauIndexe[@]}
</code></code>

    L'exécution de cette fonction dans la ligne de commande vous donnera le résultat suivant :

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b4b9.jpeg" alt="Passer un Tableau à une Fonction" width="50%">


    <br><br>
    <a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Rejoignez ellohost</button></a>

</body>
</html>

Print this item

  How to Use Bash Arrays
Posted by: aaron - 07-22-2023, 05:12 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>How to Use Bash Arrays</title>
</head>
<body>
<h2>What Is a Bash Array?</h2>

    A bash array is a data structure designed to store information in an indexed way. In other words, a bash array is a large group of variables. Unlike typical arrays used in other programming languages, bash arrays can store different types of elements. For example, you can use a bash array to store both strings and numbers.


There are two types of bash arrays:
<ul>
    <li>Indexed – the array is referred via integers or numbers.</li>
    <li>Associative – the array is referred via strings or a set of characters and words.</li>
</ul>


    Remember that bash does not support multidimensional arrays, so it’s not possible to add an array within an array.


<h3>How to Declare Array in Bash</h3>

    There are a few ways to declare indexed and associative arrays in bash. It’s worth noting that the bash array size does not need to be declared beforehand because bash arrays have no upper limit on the number of elements they can store.


<h4>Indexed Array</h4>

    We will start with a simple bash indexed array. For example, we’ll use it to create a list of different means of transportation.

<code><code>
declare -a IndexedArray
IndexedArray[0]=car
IndexedArray[1]=plane
IndexedArray[2]=bike
</code></code>

    The same can be achieved without the <code>declare</code> builtin:

<code><code>
IndexedArray[0]=car
IndexedArray[1]=plane
IndexedArray[2]=bike
</code></code>

    Or, make it even simpler by going with:

<code><code>
IndexedArray=(car plane bike)
</code></code>

    Remember that indexing starts at 0, so the above example will assign the car element of the array to the 0 index.



    However, there is an option to set an array with indices:

<code><code>
IndexedArray=([0]=’car’ [1]=’plane’ [2]=’bike’)
</code></code>

    An interesting feature of bash arrays is that following index numbers in order is not necessary. For example, you can declare only the first and third elements while leaving the second element of an array empty:

<code><code>
IndexedArray[0]=car
IndexedArray[2]=bike
</code></code>

<h4>Associative Array</h4>

    While indexed arrays don’t require the <code>declare</code> builtin, it won’t be possible to create an associative bash array without declaring it first:

<code><code>
declare -A AssociativeArray
</code></code>

    Next, add the values. Keep in mind that the key must be a string:

<code><code>
AssociativeArray[color]=blue
AssociativeArray[type]=car
AssociativeArray[topspeed]=200
</code></code>

    An alternative way would be:

<code><code>
declare -A AssociativeArray=( [color]=blue [type]=car [topspeed]=200 )
</code></code>

<h3>How to Add a Variable to a Bash Array</h3>

    Easily add bash variables using the <code>+=</code> operator. For example, the process for an indexed array would look like this:

<code><code>
IndexedArray=(car plane bike)
IndexedArray+=(motorcycle)
</code></code>

    The indexed array has a new element now. Remember that this method appends to the end of an array. Therefore, the motorcycle element will be added as the last element.



    For associative arrays, the process is very similar. Except, you need to specify the keys along with all the elements:

<code><code>
declare -A AssociativeArray
AssociativeArray[color]=blue
AssociativeArray+=([tires]=alloy [engine]=gasoline)
</code></code>

<h3>How to Reference and Print an Array Element</h3>

    Users can reference bash array values using the element index or key. To do this, create an indexed array:

<code><code>
IndexedArray=(car plane bike)
</code></code>

    To reference the first array variable, use the following syntax:

<code><code>
${IndexedArray[0]}
</code></code>

    Combine it with <code>echo</code>, and you will get the following:

<code><code>
echo ${IndexedArray[0]}
</code></code>

    The output will show you the first element. In this case, it’s car. The same logic applies when referencing and printing an associative array:

<code><code>
declare -A AssociativeArray=( [color]=blue [type]=car [topspeed]=200 )
echo ${AssociativeArray[type]}
</code></code>

    The output will be car as well.


    To print the whole array, use <code>@</code> as an index. The full script looks like this:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bc8f.jpeg" alt="Indexed Array Example" width="50%">

    You can also print the keys of an array instead. To do this, add an exclamation mark before the array name:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bbaa.jpeg" alt="Associative Array Example" width="50%">

<h3>How to Remove Bash Array Elements</h3>

    Deleting array elements is similar to referencing them. Use an index or a key combined with the <code>unset</code> builtin to delete an array element.


    Here’s an example of deleting a single element from an indexed array:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bb42.jpeg" alt="Delete Indexed Array Element" width="50%">

    A similar logic applies to associative arrays:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5bad6.jpeg" alt="Delete Associative Array Element" width="50%">

    To delete an entire array, specify <code>unset</code> with the array name as shown here:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b96a.jpeg" alt="Delete Entire Array" width="50%">

    Nothing is shown after trying to print the array elements because the <code>unset</code> builtin deleted them.


<h3>How to Loop Through an Array</h3>

    Creating bash loops is a fundamental aspect of learning bash scripting basics. You can use loops with arrays as well. For example, the most common use case is to iterate over each array item:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b8f1.jpeg" alt="Loop Through Array" width="50%">

    You can also combine keys with the array elements and print them all together like this:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b7c7.jpeg" alt="Loop Through Associative Array" width="50%">

<h3>How to Pass an Array to a Function</h3>

    Functions save a considerable amount of time when scripting. Instead of writing the same code repeatedly, you can call out an already written function. We will combine the codeviously mentioned iteration loop and make a function out of it:

<code><code>
function Iteration
{
m=${#IndexedArray[@]}
for (( i=0; i<m; i++ ))
do
echo ${IndexedArray[$i]}
done
}
IndexedArray=(car bike plane)
Iteration ${IndexedArray[@]}
</code></code>

    Running it on the command line will get you the following result:

<img src="https://ellohost.com/imageshack/uploads/1690002443_64bb640b5b4b9.jpeg" alt="Pass Array to Function" width="50%">


    <br><br>
    <a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Join ellohost</button></a>

</body>
</html>

Print this item

  Comment concaténer des chaînes en Bash
Posted by: aaron - 07-22-2023, 04:56 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>Comment concaténer des chaînes en Bash : Un guide pour connecter des variables de chaîne</title>
</head>
<body>
    <h1>Comment concaténer des chaînes en Bash : Un guide pour connecter des variables de chaîne</h1>

    <h2>Concaténation de chaînes - Ajout d'une variable de chaîne après l'autre</h2>
    <ul>
        <li>La méthode la plus simple de concaténation de chaînes consiste à ajouter une variable de chaîne après l'autre. Les sections suivantes montreront trois façons différentes de le faire.</li>
    </ul>
<h3>Concaténation de chaînes à l'aide de chaînes littérales</h3>
    Les chaînes littérales sont imprimées littéralement, et il y a deux façons d'imprimer une chaîne littérale - en utilisant des guillemets simples ou un symbole de barre oblique inversée avec des guillemets doubles réguliers. Par exemple, nous allons créer une nouvelle variable de chaîne littérale sans guillemets et l'afficher avec echo :
<code>
#!/bin/bash
variablename=\usr\bin\env
echo "$variablename"
    </code>
Dans ce cas, le résultat serait :
    <code>
# Résultat
usrbinenv
    </code>
Maintenant, lorsque nous ajoutons des guillemets simples ou doubles au nom de la variable de chaîne, la commande echo affichera la valeur littéralement :
<code>
#!/bin/bash
variablename='\usr\bin\env'
echo "$variablename"
    </code>
Voici le résultat :
<code>
# Résultat
\usr\bin\env
    </code>
Ensuite, nous appliquerons cette logique pour concaténer deux chaînes :
<code>
#!/bin/bash
variablename='\usr\bin\env'
echo "$variablename Bash_est_génial"
</code>
Nous pouvons également couvrir la dernière ligne de la variable en utilisant des crochets pour la protéger. Les accolades sont utiles si vous avez plusieurs variables :
<code>
echo "${variablename} Bash_est_génial"
    </code>
Dans les deux cas, le résultat sera affiché comme suit :
<code>
\usr\bin\env Bash_est_génial
    </code>

<h3>Concaténation de plusieurs variables de chaîne</h3>
Il est facile de joindre plusieurs variables de chaîne ensemble avec une manipulation de variable claire.

Par exemple, dans le script bash suivant, nous utiliserons trois variables différentes pour créer des valeurs combinées. La commande echo affichera ensuite les données de chaîne :

    <code>
#!/bin/bash
variablename='\usr\bin\env '
myvariable='_Génial'
anothervariable="$variablename"Bash_est"$myvariable"
echo "$anothervariable"
    </code>
Voici à quoi ressemblera le résultat :

    <code>
\usr\bin\env Bash_est_génial
    </code>

    <h3>Concaténation de nombres et de chaînes</h3>
    Bash permet à ses utilisateurs de concaténer une ou plusieurs variables qui ne sont pas de type chaîne. Pour cette raison, il est possible de concaténer plusieurs variables, qui peuvent être des chaînes ou des nombres :

    <code>
#!/bin/bash
firstvariable="Bonjour, le monde"
secondvariable="Bonjour, Hostinger"
thirdvariable="Je sais maintenant comment concaténer des chaînes en bash."
fourthvariable="$secondvariable et $firstvariable signifie $thirdvariable"
echo $fourthvariable
    </code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e3553.jpeg" width="60%">
<h2>Concaténation de chaînes à l'aide de l'opérateur +=</h2>
Une autre façon de joindre deux chaînes ou plus pour en créer une concaténation est d'utiliser l'opérateur d'ajout (+=). Cet opérateur permet de connecter des chaînes à l'aide d'une ou plusieurs variables.

Par exemple, le script suivant peut être utilisé pour joindre deux chaînes à l'aide d'une seule variable :

<code>
#!/bin/bash
mystring="Je voudrais générer une sortie significative, s'il vous plaît. "
mystring+="Pas de chance, mon ami !"
echo "$mystring"
</code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e34d2.jpeg" width="60%">

Un résultat similaire peut être obtenu en utilisant deux variables :

<code>
#!/bin/bash
firststring="Ceci est une seule chaîne. "
secondstring="Ce qui en fait une chaîne résultante."
# Curly brackets entre $secondvariable sont appelées interpolation de variable.
firststring+="${secondstring}"
echo $firststring
</code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e345c.jpeg" width="60%">

<h3>Concaténation de chaînes numériques</h3>
La méthode de l'opérateur d'ajout peut également être utilisée exclusivement pour ajouter des variables de chaîne numérique.

<code>
#!/bin/bash
numeric_string=2050
numeric_string+=0502
echo $numeric_string
</code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e33d5.jpeg" width="60%">

Cependant, si vous souhaitez ajouter les chiffres ensemble, cette logique doit être utilisée :

<code>
#!/bin/bash
x=3
y=5
z=6
((x+=y+=z))
echo $x
</code>

<img src="https://ellohost.com/imageshack/uploads/1690000929_64bb5e21d1910.jpeg" width="60%">

<h2>Concaténation de chaînes à l'aide de la boucle for Bash</h2>
Une façon plus avancée d'utiliser la fonctionnalité de concaténation de bash consiste à l'implémenter dans la boucle for bash.

Dans l'exemple suivant, nous avons une variable myvariable avec trois chaînes et une variable nommée results avec une chaîne vide. Avec l'aide de la boucle for bash, nous pourrons combiner les chaînes de myvariable avec notre chaîne :

<code>
#!/bin/bash
myvariable="bash concatenation Hostinger"
results=""
for i in $myvariable
do
results+="La réponse est $i... "
done
echo $results
</code>

<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e32d3.jpeg" width="60%">

<br><br>
<a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Rejoindre ellohost</button></a>
</body>
</html>

Print this item

  How to Concatenate Strings in Bash: A Guide for Connecting String Variables
Posted by: aaron - 07-22-2023, 04:51 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>How to Concatenate Strings in Bash: A Guide for Connecting String Variables</title>
</head>
<body>
    <h1>How to Concatenate Strings in Bash: A Guide for Connecting String Variables</h1>

    <h2>String Concatenation – Adding One String Variable After the Other</h2>
    <ul>
        <li>The simplest string concatenation method is adding one string variable after the other. The following sections will show three different ways to do just that.
        </li>
    </ul>
<h3>String Concatenation Using Literal Strings</h3>
    Literal strings are printed literally, and there are two ways to print out a string literal – using singular quotes or a backlash symbol with regular double quotes. For example, we will create a new literal string variable without quotes and echo it:
<code>
#!/bin/bash
variablename=\usr\bin\env
echo "$variablename"
    </code>
In this case, the result would be:
    <code>
# Result
usrbinenv
    </code>
Now, when we add singular or double quotes to the string variable name, the echo command will print the value literally:
<code>
#!/bin/bash
variablename='\usr\bin\env'
echo "$variablename"
    </code>
Here’s the result:
<code>
# Result
\usr\bin\env
    </code>
Next, we will apply this logic to concatenate two strings:
<code>
#!/bin/bash
variablename='\usr\bin\env'
echo "$variablename Bash_Is_Awesome"
</code>
We can also cover the last line’s variable using rounded brackets in order to guard it. Curly brackets are helpful if you got a variety of variables:
<code>
echo "${variablename} Bash_Is_Awesome"
    </code>
In both cases, the result will be shown as:
<code>
\usr\bin\env Bash_Is_Awesome
    </code>

<h3>String Concatenation of Multiple Variables</h3>
Multiple string variables can be easily joined together with clear-cut variable manipulation.
For example, in the following bash script, we will use three different variables to create combined values. The echo command will subsequently print out the string data:

    <code>
#!/bin/bash
variablename='\usr\bin\env '
myvariable='_Awesome'
anothervariable="$variablename"Bash_Is"$myvariable"
echo "$anothervariable"
    </code>
Here’s what the result will look like:

    <code>
\usr\bin\env Bash_Is_Awesome
    </code>

    <h3>String Concatenation of Numbers and Strings</h3>
    Bash allows its users to concatenate one or more variables that are not string-type. For this reason, it is possible to concatenate multiple variables, which can be strings or numbers:

    <code>
#!/bin/bash
firstvariable=" Hello, World "
secondvariable="Hello, Hostinger "
thirdvariable=" I now know how to concatenate strings in bash."
fourthvariable="$secondvariable"and"$firstvariable"means"$thirdvariable"
echo $fourthvariable
    </code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e3553.jpeg" width="60%">
<h2>String Concatenation Using the += Operator</h2>
Another way to join two or more strings to make a concatenated string is to use the addition assignment operator (+=). This operator makes it possible to connect strings using one or more variables.
For example, the following script can be used to join two strings with the use of a single variable:
<code>
#!/bin/bash
mystring="I would like to generate a meaningful output, please. "
mystring+="Not a chance, friend!"
echo "$mystring"
    </code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e34d2.jpeg" width="60%">

A similar result can be achieved using two variables:
<code>
#!/bin/bash
firststring="This is a single string. "
secondstring="Which makes this a resulting string."
# Curly brackets between $secondvariable are called variable interpolation.
firststring+="${secondstring}"
echo $firststring
    </code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e345c.jpeg" width="60%">

<h3>Concatenating Numeric Strings</h3>
The append operator method can also be used exclusively to append numeric string variables.

    <code>
#!/bin/bash
numeric_string=2050
numeric_string+=0502
echo $numeric_string
    </code>
<img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e33d5.jpeg" width="60%">
However, if you would like to add the numbers together, this logic needs to be used:

    <code>
#!/bin/bash
x=3
y=5
z=6
((x+=y+=z))
echo $x
    </code>

<img src="https://ellohost.com/imageshack/uploads/1690000929_64bb5e21d1910.jpeg" width="60%">

<h2>Concatenating Strings Using Bash for Loop</h2>
    A more advanced way of using the bash concatenate functionality is implementing it into the bash for loop.

In the following example, we got a myvariable with three strings and a variable named results with an empty string. With the help of the bash for loop, we will be able to combine strings from myvariable with our string:

    <code>
#!/bin/bash
myvariable="bash concatenation Hostinger"
results=""
for i in $myvariable
do
results+="The answer is $i... "
done
echo $results
    </code>

    <img src="https://ellohost.com/imageshack/uploads/1690000727_64bb5d57e32d3.jpeg" width="60%">

    <br><br>
    <a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Join ellohost</button></a>
</body>
</html>

Print this item

  Comment protéger un site web avec un mot de passe
Posted by: aaron - 07-22-2023, 04:29 AM - Forum: Others - No Replies

<!DOCTYPE html>
<html>
<head>
    <title>Comment protéger un site web avec un mot de passe</title>
</head>
<body>
<h1>Comment protéger un site web avec un mot de passe</h1>
<ul>
<li>Pour protéger l'accès à votre site web via une authentification par nom d'utilisateur et mot de passe, vous devrez télécharger un fichier .htaccess et un fichier htpasswd à la racine de votre compte FTP en utilisant FileZilla ou un logiciel de transfert FTP similaire.</li>
</ul>
Le fichier <code>.htaccess</code> contiendra le chemin où les noms d'utilisateur et mots de passe autorisés à y accéder sont stockés. Il devrait contenir le code suivant :
<pre>
AuthType Basic
AuthName "Nom d'authentification"
AuthUserFile /var/www/Mydomain.com/htdocs/.htpasswd
Require valid-user
</pre>
<p>Le terme <code>Mydomain.com</code> doit être remplacé par votre nom de domaine.</p>
<ul>
<li>Le fichier <code>.htpasswd</code> contiendra le nom d'utilisateur autorisé à se connecter ainsi que son mot de passe, qui sera crypté. La création des fichiers <code>.htaccess</code> et <code>.htpasswd</code> peut être effectuée via un éditeur de texte tel que Notepad.</li>
</ul>
<p>Information : les fichiers <code>.htaccess</code> et <code>.htpasswd</code> sont des fichiers cachés, il est donc possible que lorsque vous effectuez une connexion FTP via un logiciel de transfert FTP, vous ne les voyiez pas. Dans ce cas, il sera nécessaire d'afficher les fichiers cachés dans votre logiciel.</p>
<p><a href="https://ellohost.com"><button style="padding: 10px 20px; background-color: blue;">Rejoindre ellohost</button></a></p>
</body>
</html>

Print this item