Pages

Thursday, December 21, 2023

Streamlining Collaboration: Setting Up a Password-Free Git Environment

In the world of software development, efficient and secure collaboration is key. One fundamental aspect of this is ensuring your Git master and client servers can communicate seamlessly and securely. This blog post will guide you through setting up a password-free connection between your Git master and client servers, establishing a smooth workflow for your development needs.

Prerequisites

Before diving into the setup, ensure that both the Git master and client servers can connect to each other and have proper hostnames set. This initial step is crucial for a hassle-free process.

Step 1: Host Recognition

Start by making sure that the master and client recognize each other. This can be done by adding entries to the /etc/hosts file on both servers.

On the Master:

echo "x.x.x.x master.gitserver.com" >> /etc/hosts

On the Client:

echo "x.x.x.x client.gitserver.com" >> /etc/hosts

Replace "x.x.x.x" with the respective IP addresses.

Step 2: Setting the Hostname

Assign a hostname to each server to ensure they are identifiable within your network.

On the Master:

hostname master.gitserver.com

On the Client:

hostname client.gitserver.com

Step 3: Password-Free Connectivity

To facilitate a seamless connection, set up SSH keys to allow the master and client to communicate without requiring a password.

  • Use ssh-keygen to generate an SSH key pair.
  • Use ssh-copy-id to copy the public key to the other server.

Refer to detailed guides like Creating a Password-Free Connection for step-by-step instructions.

Step 4: Create a Dedicated Git User

For security purposes, create a dedicated 'git' user on both servers and conduct all operations under this user.

useradd -m git

Step 5: Setting Up the Git Repository

On the Master Server, create a directory for your Git projects:

mkdir /home/git/GIT-Projects

Inside this directory, create a project folder:

mkdir /home/git/GIT-Projects/proc1

Initialize the project directory as a bare Git repository:

cd /home/git/GIT-Projects/proc1 git init --bare

Client-Side Configuration

Now, move to the client side to set up your local repository:

  1. Create a local directory for your project:

    mkdir /home/git/prod1 cd /home/git/prod1
  2. Initialize the local directory as a Git repository:

    git init
  3. Prepare your files and make the initial commit:

    touch {1..2} git add * git commit -m "First Commit"
  4. Link your local repository to the master server:

    git remote add origin git@master.gitserver.com:/home/git/GIT-Projects/proc1
  5. Push your changes to the master server:

    git push origin master

Branching Out

If you want to push to a different branch, you can do so easily:

git push -u origin master:anotherBranch

Conclusion

By following these steps, you've established a robust, secure, and efficient environment for Git collaboration. Your master and client servers can now communicate without passwords, streamlining your workflow and keeping your focus on development. Remember, a well-set-up environment is a precursor to productive, hassle-free development experiences. Happy coding!

Creating a Password-Free Connection Between Two Servers with Proper Permissions

Creating a Password-Free Connection Between Two Servers with Proper Permissions

Setting up a password-free SSH connection between two servers, A and B, enhances security and efficiency. This guide will walk you through establishing a secure, key-based connection, ensuring all permissions are correctly set to 600 for safety.

Step 1: Generate SSH Keys

  • On Both Server A and B:

    1. Run ssh-keygen to create a pair of keys: id_rsa (private) and id_rsa.pub (public).
    2. Ensure the permissions of these keys are set to 600.

Step 2: Exchange Public Keys

  • On Server A:
    1. Copy the id_rsa.pub of Server A to the authorized_keys file of Server B.
  • On Server B:
    1. Similarly, copy the id_rsa.pub of Server B to the authorized_keys file of Server A.

Connecting Using Private Key:

  • To connect to Server A from B (or vice versa), use the private key (id_rsa) with the following command:
    ssh user@xxx.xxx.xxx.xxx -i <path-to-private-key>
    Replace xxx.xxx.xxx.xxx with the actual server IP and specify the correct path to your private key.

Additional Tips:

  • From any other server (say Server Z with IP zzz.zzz.zzz.zzz), you can use the ssh-copy-id command to easily copy your public key to Servers A or B:
    ssh-copy-id root@zzz.zzz.zzz.zzz
  • Reverse the process to allow the opposite connection.

Important Notes:

  • Always ensure your keys' permissions are set to 600 to prevent unauthorized access.
  • Regularly update and rotate your keys for enhanced security.

By following these steps, you'll establish a secure, password-free connection between two servers, ensuring efficient and safe operations.

Friday, November 3, 2023

Plex Media Server Issue: "Failed to Load Preferences" - Solution

Plex Media Server is a popular media management platform, but like any software, it can encounter issues. One common problem users might face is the "Failed to load preferences" error. In this blog post, we'll explore this issue and provide a solution.


Issue Description:

When attempting to start the Plex Media Server, you might encounter the following error message:

Failed to load preferences at /var/lib/plexmediaserver/Library/Application Support/Plex Media Server

This error indicates a problem with loading preferences for Plex Media Server.


Solution:

Step 1: Stop Plex Media Server

Before proceeding with the solution, stop the Plex Media Server. You can do this using the following command:

sudo systemctl stop plexmediaserver

Step 2: Rename Preferences Directory

The "Failed to load preferences" error often occurs due to a corrupted or misconfigured preferences directory. To resolve this issue, you can rename the existing preferences directory, and Plex Media Server will create a new one.

sudo mv /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server.bak

This command renames the preferences directory to create a backup.

Step 3: Restart Plex Media Server

Now, start Plex Media Server again:

sudo systemctl start plexmediaserver

Step 4: Verify Operation

Check the status of Plex Media Server to ensure it's running without any errors:

sudo systemctl status plexmediaserver

If everything is working as expected, you should see Plex Media Server as "active (running)" in the status output.

Thursday, August 24, 2023

Generating SSL Certificates for Websites on Non-Standard Ports

Ensuring secure communication is essential for websites, even if they are not published on the default ports 80 or 443. This guide demonstrates how to obtain SSL certificates using Certbot when your website is hosted on a non-standard port. We'll walk through the steps using a generalized URL and domain name for clarity.

Prerequisites

Before starting, make sure you have the following:
  • A server hosting your website is accessible via a specific port.
  • Domain name and DNS management access for the domain.

Step 1: Install Certbot

Begin by installing Certbot using the following commands

sudo dnf install epel-release -y sudo dnf install certbot -y

Step 2: Generate SSL Certificate


Generate an SSL certificate using Certbot's manual mode with DNS challenge. Replace your.domain.com with your actual domain name.

sudo certbot --manual --preferred-challenges dns certonly -d your.domain.com

Follow the prompts provided by Certbot. You'll be asked to add a specific DNS TXT record to your DNS configuration to prove domain ownership.

Step 3: Certificate Location


Upon successful completion, Certbot will provide a confirmation message and indicate the location where the certificate and key files are stored. These files will be required for your web server's SSL configuration plaintext

Certificate is saved at: /etc/letsencrypt/live/your.domain.com/fullchain.pem 
Key is saved at: /etc/letsencrypt/live/your.domain.com/privkey.pem

Step 4: Next Steps


The certificate obtained is not set to automatically renew. To renew it, repeat the same Certbot command before the certificate's expiration date.

Remember, you'll need to configure your web server to use the obtained SSL certificate. or else replace the old certificates with new certificates with same name.

Wednesday, August 16, 2023

Resolving File Update Issues in Nextcloud: Correcting Permissions and Indexing

Modern cloud storage solutions like Nextcloud offer seamless file synchronization and sharing capabilities, enhancing collaboration and accessibility. However, sometimes you might encounter issues where manually copied files fail to get updated or indexed. This blog post provides insights into tackling this problem and presents commands to correct file permissions and trigger file indexing in Nextcloud.

Understanding the Issue

When manually copying files into your Nextcloud directory, you might notice that these files don't seem to sync or get indexed properly. This discrepancy can often be attributed to incorrect permissions or a lack of indexing triggers within the Nextcloud environment.


Correcting Permissions

File permissions play a crucial role in ensuring that the Nextcloud server can access, modify, and index files appropriately. Incorrect permissions can lead to issues such as files not being recognized or processed by Nextcloud.

To rectify this, you can adjust the ownership of your Nextcloud directory using the chown command. The following command changes the ownership of the Nextcloud directory to the nginx user and group:
sudo chown nginx. -R /PATH TO THE NEXTCLOUD DIRECTORY/ABC/nextcloud
This ensures that the Nextcloud server has access to your files for indexing and synchronization. In case we are using an Apache server relevant user has to be added. 


Triggering File Indexing

Nextcloud relies on indexing to keep track of file changes and updates. If manually copied files aren't being indexed automatically, you can initiate the indexing process using the occ command-line tool.
Use the following command to run a full file scan and index all files in your Nextcloud installation:

sudo -u nginx /PATH TO THE NEXTCLOUD DIRECTORY/ABC/nextcloud/occ files:scan --all
This command runs the indexing process under the nginx user, ensuring that the permissions are correctly managed throughout the process.