---
title: How to deploy website using git on a VPS server.
description: "This guide will walk you through the process of performing system updates, installing Git, generating an SSH key pair, copying the public key to GitHub, cloning a repository, and troubleshooting common issues. NOTE: This guide uses **AlmaLinux OS** ## **1.…"
url: "https://truehost.com/support/knowledge-base/how-to-deploy-website-using-git-on-a-vps-server/"
updated: "2025-02-10"
category: Servers
---

# How to deploy website using git on a VPS server.

This guide will walk you through the process of performing system updates, installing Git, generating an SSH key pair, copying the public key to GitHub, cloning a repository, and troubleshooting common issues.

NOTE: This guide uses **AlmaLinux OS**

## **1. Perform System Updates**

Before making any changes or installing new software, it's crucial to ensure that your system is up-to-date.

***`yum -y updateyum clean all`***

![](https://truehost.com/support/wp-content/uploads/2025/02/image-30-1024x255.png)

## **2. Install Git**

Git is a version control system that allows you to track changes in your code and collaborate with others. To install Git on your server, run the following command:

**`yum -y install git`**

![](https://truehost.com/support/wp-content/uploads/2025/02/image-31-1024x228.png)

This command installs Git and all its dependencies.

## **3. Generate an SSH Key Pair**

SSH keys provide a secure way to log into your server and authenticate with GitHub without using a password. To generate an SSH key pair, use the following command:

***`ssh-keygen -t rsa -b 4096 -C "example@domain.com"`***

Replace `"example@domain.com"` with your email address. This command creates a 4096-bit RSA key pair.

![](https://truehost.com/support/wp-content/uploads/2025/02/image-32-1024x374.png)

## **4. Copy the Public Key to GitHub**

After generating the SSH key pair, you need to copy the public key to GitHub to enable secure communication between your server and GitHub.

Change to the `.ssh` directory:

***`cd ~/.ssh`***

Display the public key using the `cat` command:

**`cat id_rsa.pub`**

![](https://truehost.com/support/wp-content/uploads/2025/02/image-33-1024x386.png)

Copy the output, which is your public key.

Log in to GitHub and navigate to **Your** **Profile** > **Settings** > **SSH and GPG Keys**.

Click on the **New SSH Key** button.

![](https://truehost.com/support/wp-content/uploads/2025/02/image-34-1024x347.png)

Give the key a descriptive title and paste the public key into the **Key** field.

Click **Add SSH Key** to save it

![](https://truehost.com/support/wp-content/uploads/2025/02/image-36-1024x384.png)

## ** 5. Clone Your Repository on Your Server**

Once the SSH key is set up, you can clone your repository to your server.

Navigate to the directory where you want to clone the repository

***`cd /var/www/domain.com/public_html`***

Clone the repository:

***`git clone git@github.com:username/repo-name.git .`***

Replace `username` and `repo-name` with your GitHub username and repository name, respectively.

![](https://truehost.com/support/wp-content/uploads/2025/02/image-37-1024x388.png)

## ** 6. Reload Your Site**

After cloning the repository, your site should now load with the content from the repository. Access your site to confirm it is now accessible.

![](https://truehost.com/support/wp-content/uploads/2025/02/image-38-1024x437.png)

If you make changes locally and push them to the remote repository, you can pull the latest changes to your server using:

***`git pull origin main`***

Replace `main` with the branch name you want to pull (e.g., `master` or another branch).

## **7. Conclusion.**

Congratulations. You've successfully deployed your application to the VPS server using Git.

Happy Hosting.
