Share this post on:

Introduction

I use GIT on my local server to track changes for my automation scripts. I also use it to be synced with remote GitHub repositories. Recently, I migrated all my servers to Centos 8 and had to re-configure my Git.

On local server

First, we need to authenticate with a remote repository on GitHub. GitHub uses SSH keys as authentication so we need to create a pair of RSA SSH keys.

ssh-keygen -t rsa -C "pawel@kuligowski.co.uk"

Once created, let’s copy our public key into the GitHub account:

[root@centos ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDYE2a/9QFLu++q8L9gm70fqNmYsDK+NcMVSEPwYrSVqMCOqpR3263vR7ymFM0TqRgOVvOzbVaJRr5wDdV/cTkb+Qi9e9OnrdfoiEE8uf06QVoAIs3w8fV1LrMBRiIqIb7Y94JFgJQD5R8uJOPallxqA9twYfUshkTZrwUdosVmK7Y1/dgvqkPeNWxC1I2BeZ0h2U/i43JvpF0vO5KJip9PdO+jl+UMTAqqAcPVrknzD7KOkJDDHuplGnt5ECEQsPd3JazVBiOQEjCsDF0npLtdF+huQHjAj2+zoEmWnmnQ6qS8O+w5FY8pDgCrD0BGlWfBOQJrek0N6SUG9kQqNmtNv8VmrtIpeoR+XUqBHVHW/d0i3r8UUfrRtew3AFa0uR90V8Vm9xGecYFgoaA7nlknEblxxq4NeTssUlUbIkl3L4PytbgQPg/Rkl+13lD/g7W3St/n38wYqX/YzjEfMn7chZ33rDSwPkJrkYGUfLQeHVDm0k1V6XBAXyAJqpkyGJE= pawel@kuligowski.co.uk

Now, log in to your GitHub account, go in to settings and paste the SSH key.

Cloning remote repo to local server

To copy all data from repository, create a directory on a local server and clone the repo.

[root@centos ~]# mkdir /git
[root@centos]# git clone https://github.com/pavbjj/Cisco-Ansible-Playbooks

When cloning remote repo, there’s no need to initilalize this on local server (‘git init’) as ‘git clone’ does it all for you as well as:

  • git init (create the local repository)
  • git remote add (add the URL to that repository)
  • git fetch (fetch all branches from that URL to your local repository)
  • git checkout (create all the files of the main branch in your working tree)

Leave a Comment

Your email address will not be published. Required fields are marked *