diff --git a/content/get-started/configuration.md b/content/get-started/configuration.md index 501fa19..72c9551 100644 --- a/content/get-started/configuration.md +++ b/content/get-started/configuration.md @@ -3,29 +3,41 @@ title: Pactus Node Configuration weight: 6 --- -The Pactus node can be configured via a TOML file. You can find an example configuration in the -[configurations](https://github.com/pactus-project/pactus/blob/main/config/example_config.toml) section. +## Preface -Your node configuration can be found at the following path: +The Pactus node can configure using a [TOML](https://toml.io/en/) file, +which is a simple text format for configuration. +This file is automatically created when the node initializes. +Each node can have different settings and configurations based on its needs and requirements. + +The config file can find inside the working directory, typically located at: {{< tabs items="Linux-mac,windows" >}} {{< tab >}} ```none -/home/{user}/pactus/config.toml +~/pactus/config.toml ``` {{< /tab >}} {{< tab >}} ```none -C:\Users\{user}\pactus\config.toml +C:\Users\\pactus\config.toml ``` {{< /tab >}} {{< /tabs >}} -### Example Configuration +## Editing Config File + +Modifying the TOML file is straightforward, but because TOML is sensitive to spaces, +it's important to ensure the file is formatted correctly. +Online tools like [TOML Lint](https://www.toml-lint.com/) can help check the validity of the config file. + +## Example Configuration + +Here is a example of Pactus config file.
Loading configuration...
diff --git a/content/tutorials/grpc-basic-auth.md b/content/tutorials/grpc-basic-auth.md index ee1a5f3..b2c5498 100644 --- a/content/tutorials/grpc-basic-auth.md +++ b/content/tutorials/grpc-basic-auth.md @@ -1,57 +1,58 @@ --- -title: How to secure gRPC using basic authentication? +title: How to Secure gRPC Using Basic Authentication weight: 4 --- ## Preface -The Pactus Blockchain offers a gRPC interface, enabling users to interact with both the blockchain +The Pactus Blockchain offers a gRPC interface, enabling users to interact with the blockchain and its native wallet. To enhance the security of gRPC APIs, we have implemented a Basic Authentication -mechanism. This approach aims to provide a straightforward yet effective means for authenticating clients accessing the APIs. +mechanism based on [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) password hashing. +This approach aims to provide a straightforward yet effective means for authenticating clients accessing the APIs. -**Note:** This mechanism secures gRPC, gRPC gateway, and HTTP communications. +**Note:** This mechanism secures gRPC, gRPC gateway, JSON-RPC, and HTTP communications. -## Generate Basic Auth +## Basic Auth Format -To enable basic authentication, you need to generate basic authentication credentials using an online -tool or a predefined utility. +Basic Authentication is a string of the form `username:password_hash`. +For example, if the username is "user" and the password is "pass", the Authorization header would be: -Example Format: +```text +user:$2a$10$nl6VKEzSENIK5dmzoADgKeTFtCusQxeVCZiXkRzzbyfG.bLpHtrda +``` -```shell -username: foo -password: bar +## Generate Password Hash -result: foo:$2a$10$nl6VKEzSENIK5dmzoADgKeTFtCusQxeVCZiXkRzzbyfG.bLpHtrda -``` +You can generate a bcrypt-hashed password using the following methods: -### Generate by using htpasswd tool +### Using Apache htpasswd -1. Install the `htpasswd` tool from [Apache](https://httpd.apache.org/docs/2.4/programs/htpasswd.html). -2. Use the `htpasswd` command-line tool to generate a bcrypt-hashed password. Here's the general syntax: +The [Apache htpasswd](https://httpd.apache.org/docs/2.4/programs/htpasswd.html) +is a simple application for generating password hashes. +Here is the general syntax: ```shell -htpasswd -bnBC 10 +htpasswd -bnB ``` -- `-b`: Use the command line to provide the password. -- `-n`: Output the hashed password to the console rather than updating a file. -- `-B`: Force the use of the bcrypt encryption algorithm. -- `-C cost`: Set the cost factor for the bcrypt algorithm. Higher values result in slower hashing but are more secure. -- `username`: The username for which you are generating the password. -- `password`: The password you wish to hash. +- `b`: Use batch mode to retrieve the password from the command line rather than prompting for it. +- `n`: Display the results on standard output. +- `B`: Force the use of the bcrypt algorithm. +- `username`: The username for which the password is being generated. +- `password`: The password to be hashed. Example: ```shell -htpasswd -bnBC 10 user pass +htpasswd -bnB user pass ``` This process results in a bcrypt-hashed password that can be used for basic authentication. -### Generate With Online tool +### Using Online tool -To generate basic authentication credentials, you can use the following form to create a hashed credential. +To generate basic authentication credentials, you can use this online tool here. +For additional security, you can save the web page locally and run it on an offline computer. {{}} @@ -71,19 +72,17 @@ To generate basic authentication credentials, you can use the following form to ## Enable Basic Auth in the Config -1. Open the `config.toml` file in your Pactus directory. - -- Windows:`C:\Users\{user}\pactus` -- Linux and Mac: `/home/{user}/pactus` +To enable Basic Authentication in your Pactus Blockchain configuration, follow these steps: -2. Insert the generated user with the hashed password into the `basic_auth_credential` field in the config file. +1. Open the [configuration](https://docs.pactus.org/get-started/configuration/) file in your Pactus directory. +2. Insert the generated user with the hashed password into the `basic_auth` field in the `grpc` section: ```toml [grpc] enable = true enable_wallet = false listen = "127.0.0.1:50051" -basic_auth_credential = "foo:$2a$10$nl6VKEzSENIK5dmzoADgKeTFtCusQxeVCZiXkRzzbyfG.bLpHtrda" +basic_auth = "user:$2a$10$nl6VKEzSENIK5dmzoADgKeTFtCusQxeVCZiXkRzzbyfG.bLpHtrda" ``` 3. Restart or run the node to apply this configuration. diff --git a/content/tutorials/linux-systemd.md b/content/tutorials/linux-systemd.md index df9b8e7..69efb31 100644 --- a/content/tutorials/linux-systemd.md +++ b/content/tutorials/linux-systemd.md @@ -1,137 +1,117 @@ --- -title: How to run Pactus with systemd linux? +title: How to Run Pactus with systemd on Linux weight: 8 --- -Systemd is a system and service manager for Linux operating systems. -It is designed to provide better efficiency, performance, and manageability over the traditional SysV init system. -systemd is a suite of basic building blocks for a Linux system that provides a system and service manager that -runs as PID 1 and starts the rest of the system. +## Preface + +[Systemd](https://en.wikipedia.org/wiki/Systemd) is a system and service manager for Linux that +helps manage how programs start up, run, and shut down. +It also handles system processes, logging, and basic service monitoring. ## Prerequisites +Before setting up Pactus to run with systemd, ensure you have the following: + - Download the latest version of Pactus CLI for your Linux system from [here](https://pactus.org/download/#cli). -- Systemd: This guide assumes that systemd is installed and running on your Linux distribution. -- Most modern Linux distributions use systemd by default. +- This guide assumes that `systemd` is installed and running on your Linux distribution. + Most modern distributions use `systemd` by default. -## How to create systemd service? +## Creating a systemd Service -First, create a systemd service file for `pactus-daemon` file. This file will tell systemd how to manage your service. +To create a systemd service for Pactus, follow these steps: -1. Open a terminal and create a new service file in the `/etc/systemd/system/` directory. -2. You will need superuser permissions to do this. +1. **Initialize the Pactus Node**: Before running the service, initialize the Pactus node by this command: -```shell -sudo nano /etc/systemd/system/pactus.service -``` + ```shell + pactus-daemon init + ``` -2. Add the following content to the file, replacing `{user}` with your actual username: +2. **Create a Service File**: Open a terminal and + create a new service file in the `/etc/systemd/system/` directory with superuser permissions: -```ini -[Unit] -Description=Pactus Daemon Service -After=network.target + ```shell + sudo nano /etc/systemd/system/pactus.service + ``` -[Service] -Type=simple -User={user} -ExecStart=/home/{user}/pactus-cli/pactus-daemon start -w /home/{user}/pactus -Restart=on-failure -RestartSec=10 +3. **Add the Following Content** to the service file, replacing `` with your actual username: -[Install] -WantedBy=multi-user.target -``` + ```ini + [Unit] + Description=Pactus Daemon Service + After=network.target -{{< callout type="info" >}} -Before running the service, you need to initialize the Pactus service by using `pactus-daemon init`. -{{< /callout >}} + [Service] + Type=simple + User= + ExecStart=/home//pactus-cli/pactus-daemon start -w /home//pactus + Restart=on-failure + RestartSec=10 -3. After creating or modifying the service file, - you need to reload the systemd manager configuration to recognize the new service. + [Install] + WantedBy=multi-user.target + ``` -```shell -sudo systemctl daemon-reload -``` +4. **Reload Systemd Configuration**: After creating or modifying the service file, + reload the systemd to recognize the new service: -1. To start the service immediately and enable it to start on boot, use the following commands: + ```shell + sudo systemctl daemon-reload + ``` -```shell -sudo systemctl start pactus -sudo systemctl enable pactus -``` +5. **Start and Enable the Service**: Start the service immediately and enable it to start on boot: -5. You can check the status of your service to ensure it is running correctly: + ```shell + sudo systemctl start pactus + sudo systemctl enable pactus + ``` -```shell -sudo systemctl status pactus -``` +6. **Check Service Status**: Check the status of your service to ensure it is running correctly: -```shell -● pactus.service - Pactus Daemon Service - Loaded: loaded (/etc/systemd/system/pactus.service; disabled; preset: enabled) - Active: active (running) since Sun 2024-05-26 11:12:54 +0330; 10s ago - Main PID: 90107 (pactus-daemon) - Tasks: 22 (limit: 40623) - Memory: 27.2M (peak: 28.9M) - CPU: 5.486s - CGroup: /system.slice/pactus.service - └─90107 home/{user}/pactus-cli/pactus-daemon start -w /home/{user}/pactus - -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1281 ⌘ 6E41D64CFE33 🕣 03.27.30}" block="{⌘ 6E41D64CFE33 👤 pc1p378jgjtl 💻 58CE193E0161 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1282 ⌘ 366B03DCF65A 🕣 03.27.40}" block="{⌘ 366B03DCF65A 👤 pc1plq8uyn6e 💻 F098577447DB 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1283 ⌘ D69C65555B92 🕣 03.27.50}" block="{⌘ D69C65555B92 👤 pc1pm93ykyvc 💻 CD768CBD0F2C 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1284 ⌘ D66E9A24F92A 🕣 03.28.00}" block="{⌘ D66E9A24F92A 👤 pc1pp3xtmjhz 💻 8ED750F438CA 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1285 ⌘ 8B60B8F624AD 🕣 03.28.10}" block="{⌘ 8B60B8F624AD 👤 pc1p378jgjtl 💻 964C484CC19D 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1286 ⌘ E0FA657D6E76 🕣 03.28.20}" block="{⌘ E0FA657D6E76 👤 pc1plq8uyn6e 💻 D9616D8C437E 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1287 ⌘ 077FD6637930 🕣 03.28.30}" block="{⌘ 077FD6637930 👤 pc1pm93ykyvc 💻 DA04DE4E9224 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1288 ⌘ 2954EAAFEB9F 🕣 03.28.40}" block="{⌘ 2954EAAFEB9F 👤 pc1pp3xtmjhz 💻 D1D2556F0BC1 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1289 ⌘ 4EF8FCF3141B 🕣 03.28.50}" block="{⌘ 4EF8FCF3141B 👤 pc1p378jgjtl 💻 FA9707153527 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1290 ⌘ 2F47F91619DE 🕣 03.29.00}" block="{⌘ 2F47F91619DE 👤 pc1plq8uyn6e 💻 B9924A951389 📨 1}" round> -May 26 11:13:05 15ALC6 pactus-daemon[90107]: 11:13:05 INF new block committed _state="{#1291 ⌘ 424D4CEB70AA 🕣 03.29.10}" block="{⌘ 424D4CEB70AA 👤 pc1pm93ykyvc 💻 AE210F198107 📨 1}" round> -lines 1-21/21 (END) -``` + ```shell + sudo systemctl status pactus + ``` -## Manage the Service +## Managing the Service -Here are some common commands to manage the service: +Use these commands to manage the Pactus service with systemd: -- Start the service: +- **Start the Service**: -```shell -sudo systemctl start pactus -``` + ```shell + sudo systemctl start pactus + ``` -- Stop the service: +- **Stop the Service**: -```shell -sudo systemctl stop pactus -``` + ```shell + sudo systemctl stop pactus + ``` -- Restart the service: +- **Restart the Service**: -```shell -sudo systemctl restart pactus -``` + ```shell + sudo systemctl restart pactus + ``` -- Enable the service to start on boot: +- **Enable the Service to Start on Boot**: -```shell -sudo systemctl enable pactus -``` + ```shell + sudo systemctl enable pactus + ``` -- Disable the service from starting on boot: +- **Disable the Service from Starting on Boot**: -```shell -sudo systemctl disable pactus -``` + ```shell + sudo systemctl disable pactus + ``` -## Troubleshooting +## Checking Logs -If the service fails to start or behaves unexpectedly, you can check the logs using `journalctl`: +If the service fails to start or behaves unexpectedly, check the logs using `journalctl`: ```shell sudo journalctl -u pactus.service ``` -This command will show you the log entries related to your service, which can help you diagnose issues. +This command will show you the log entries related to your service, helping you diagnose issues.