Cloning a Private Repository into a CentOS Server
This tutorial outlines the steps to clone a private Git repository into a CentOS server.
Prerequisites
- A CentOS server
- Access to a private repository (e.g., on GitHub)
Steps
1. Install Git on CentOS
First, update your package manager and install Git:
sudo yum update
sudo yum install git
2. Set Up SSH Keys (for SSH authentication)
If using SSH for authentication, set up SSH keys:
Generate a New SSH Key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Follow the prompts
Add Your SSH Key to the SSH-Agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
Copy the SSH Key
cat ~/.ssh/id_rsa.pub
# Copy the output
3. Add the SSH Key to Your GitHub Account
Steps
- Log into your GitHub account.
- Go to Settings > Deploy keys.
- Click on Add Deploy key.
- Paste your copied SSH key and add a descriptive title.
- Click Add SSH key.
4. Clone the Repository
Navigate to the desired directory and use the git clone
command:
git clone git@github.com:username/repository.git
# Replace with your repository's SSH URL
For HTTPS, replace the URL accordingly. You might be prompted to enter your credentials if it’s a private repository.
Conclusion
After these steps, you should have the private repository cloned into your CentOS server. You can now navigate to the repository’s directory and start working on it.