Admins and Developers Guide to Manage your Scripts & Files

The Easy way to Setup your Home or Office Git Server

Introduction

git logo credit git website

What About Windows and MacOS

  1. Run the PuTTYgen program.
  2. The PuTTY Key Generator window is displayed.
  3. Set the Type of key to generate an option to SSH-2 RSA.
  4. In the Number of bits in a generated key box, enter 2048.
  5. Click Generate to generate a public/private key pair.
  6. As the key is being generated, move the mouse around the blank area as directed.
  7. (Optional) Enter a passphrase for the private key in the Key passphrase box and reenter it in the Confirm passphrase box.
  8. Click save your private keys and public keys to file then copy the contents of the public key to the git server
  9. Open Putty and Configure SSH option to point to the private key file

The Setup

> yum install git -y> vi /etc/hosts10.131.92.196 gitserver.local.domain gitserver
10.131.92.195 client.local.domain client
> useradd git
>  su git
> cd
> mkdir -p gitdata
> cd gitdata
> git init --bare
Initialized empty Git repository in /home/git/gitdata
> ls
branches config description HEAD hooks info objects refs
> mkdir .ssh && chmod 700 .ssh
> touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
> useradd jdoe
> su jdoe
> cd
> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jdoe/.ssh/id_rsa):
Created directory '/home/jdoe/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/jdoe/.ssh/id_rsa.
Your public key has been saved in /home/jdoe/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:0AuYW2upQBgOlWhw6PQ7PHAoLi4vRoyHcal90Ceryy0 jdoe@client.local.domain
The key's randomart image is:
+---[RSA 2048]----+
|=+o. |
|=*. o . |
|=.+oo + . |
|o=+ooo.= . |
|=*=.o++ S |
|=+o*oo |
|+. o+ |
|o+E. |
|oo+o. |
+----[SHA256]-----+
> cd .ssh
> cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCWP3u09b1VbdY65LGIHfUikC/ccB/tztGzHEw7JHEo zfiXcKj4zk5ViyLxBVRcKW0nkB6Hw5lsDIFkbWMdGPPtyNs+QrFt0McjVhgY9e8B3Urvclk6DRPeBxkq 5qfqwQOKdgpZ5/6WG2LVPONvAhTDjPpWyLnvJ8JZh8px8nr9bidQoTe5MVwlnBpPL31JRVbBD3mEmAyk nRenp6AmWiTBWTLDk5TT8JCq2+P9L0I0IWb5n5+NVwWmzgCFBoJ8uBhaQMTl0FRWbli7qZHRyPaV3gdk hAvGNCnERIAqlgw6r/ik+SkRV7Iq7URiFWHbu9OLhh7cnC2+roTGPbAGeirT jdoe@client.local.d omain
> vi .ssh/authorized_keysssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCWP3u09b1VbdY65LGIHfUikC/ccB/tztGzHEw7JHEozfiXcKj4zk5ViyLxBVRcKW0nkB6Hw5lsDIFkbWMdGPPtyNs+QrFt0McjVhgY9e8B3Urvclk6DRPeBxkq5qfqwQOKdgpZ5/6WG2LVPONvAhTDjPpWyLnvJ8JZh8px8nr9bidQoTe5MVwlnBpPL31JRVbBD3mEmAyknRenp6AmWiTBWTLDk5TT8JCq2+P9L0I0IWb5n5+NVwWmzgCFBoJ8uBhaQMTl0FRWbli7qZHRyPaV3gdkhAvGNCnERIAqlgw6r/ik+SkRV7Iq7URiFWHbu9OLhh7cnC2+roTGPbAGeirT jdoe@client.local.domain
> ssh git@gitserver.local.domain
Enter passphrase for key ‘/home/jdoe/.ssh/id_rsa’:
Last login: Mon Oct 22 11:11:36 2018
>  vi .gitconfig
[user]
name = JOHN DOE
email = jdoe@client.local.domain
>  mkdir project1
> cd project1
> echo "this is my git project file" > projectfile.txt
> git init
Initialized empty Git repository in /home/jdoe/project1/.git/
> git commit -m 'Initial Commit'
[master (root-commit) e39ddbe] Initial Commit
1 file changed, 1 insertion(+)
create mode 100644 projectfile.txt
> git remote add origin git@gitserver.local.domain:gitdata> git push origin masterEnter passphrase for key '/home/jdoe/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 247 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@gitserver.local.domain:gitdata
* [new branch] master -> master
> cat  .git/config[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote “origin”]
url = git@gitserver.local.domain:gitdata
fetch = +refs/heads/*:refs/remotes/origin/*
>  useradd sara > ssh-keygen -t rsa 

Generating public/private rsa key pair.
Enter file in which to save the key (/home/sara/.ssh/id_rsa):
Created directory '/home/sara/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/sara/.ssh/id_rsa.
Your public key has been saved in /home/sara/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:y+Z6+kh56raDMsztu5NoavS5OnQVJk20z27aG5q8n6A sara@client.local.domain
The key's randomart image is:
+---[RSA 2048]----+
| +o |
| . +. |
| o.. |
| .o |
| . oS |
| o . .o . |
|oooo.+o+= |
| oBoB.X*+ |
|o+oE=%X%+ |
+----[SHA256]-----+
> cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTqih0FGHhcNMqMEJPI9oKmwveBTvxIg4DwYqhJp/uV3EygMj66OTb8mB05C4fRMRlPuagCCLgroaNt8/ylW3qAI2n+/sJNJmOuZCT0O850B0l3/zpHwdmjzFFXrqSqTAI4RxFR3Y1oKSOJ4YgxDq6sb0CtPP2HZVtwR08PPmQo6n8f6y8nw0Nk06hAdEH7RScD0CSu9pSiP+d/gzhPG4dlvKPnriOAxHtcO7a1+3ly2+mefAXSrZHrJkvDQdpPynemZWUa56sEXmQaG4ZFtpx5mXbmV0ckZ+nt4vHIJE+npTDSxEwyiVfksPupFfUpcoH6RdGHLknh3FDTJKPPNhz sara@client.local.domain
>  vi .ssh/authorized_keys...
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTqih0FGHhcNMqMEJPI9oKmwveBTvxIg4DwYqhJp/uV3EygMj66OTb8mB05C4fRMRlPuagCCLgroaNt8/ylW3qAI2n+/sJNJmOuZCT0O850B0l3/zpHwdmjzFFXrqSqTAI4RxFR3Y1oKSOJ4YgxDq6sb0CtPP2HZVtwR08PPmQo6n8f6y8nw0Nk06hAdEH7RScD0CSu9pSiP+d/gzhPG4dlvKPnriOAxHtcO7a1+3ly2+mefAXSrZHrJkvDQdpPynemZWUa56sEXmQaG4ZFtpx5mXbmV0ckZ+nt4vHIJE+npTDSxEwyiVfksPupFfUpcoH6RdGHLknh3FDTJKPPNhz sara@client.local.domain
> ssh git@gitserver.local.domain
The authenticity of host ‘gitserver.local.domain (10.131.92.196)’ can’t be established.
ECDSA key fingerprint is SHA256:thRRmC+M31SYsBOp+gSPiwoe81nkVwPmUCVMYVJG5Dg.
ECDSA key fingerprint is MD5:98:d1:08:0f:10:58:ab:e0:9b:81:f3:d5:46:5d:62:42.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘gitserver.local.domain,10.131.92.196’ (ECDSA) to the list of known hosts.
Enter passphrase for key ‘/home/sara/.ssh/id_rsa’:
Last login: Mon Oct 22 11:50:51 2018
[git@gitserver ~]$ exit
logout
Connection to gitserver.local.domain closed.
[sara@client .ssh]$
> git clone git@gitserver.local.domain:gitdata

Cloning into 'gitdata'...
Enter passphrase for key '/home/sara/.ssh/id_rsa':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
> ls
gitdata
> vi .gitconfig[user]
name = SARA ANDERSON
email = sara@client.local.domain
> cd gitdata/
> ls
projectfile.txt
> cat projectfile.txt
this is my git project file
> vi projectfile.txt
this is my git project file
#
We need to add more text files to this project
We need a road map to plan.
> git commit -am ' Instructions Added'

[master f73b292] Instructions Added
1 file changed, 4 insertions(+)
> git push origin masterEnter passphrase for key '/home/sara/.ssh/id_rsa':
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 342 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@gitserver.local.domain:gitdata
e39ddbe..f73b292 master -> master
> git log
commit f73b29290b48e1b40cb5eacbd37ad5539a8b3d46
Author: SARA ANDERSON <sara@client.local.domain>
Date: Mon Oct 22 12:04:20 2018 +0000
Instructions Added
commit e39ddbec3f2def4d80360483b13fc02e1e148572
Author: John Doe <jdoe@client.local.domain>
Date: Mon Oct 22 11:24:55 2018 +0000
Initial Commit

Bonus

> vi .gitconfig......[color]
diff = auto
interactive = auto
ui = true
pager = true[color "status"]
added = green
changed = red bold
untracked = magenta bold
[color "branch"]
remote = yellow

I have Windows though

Last Words

Disclaimer

--

--

--

Writer, Engineer, Cyber security enthusiast ,PhD. Candidate & 4 Open Source write about my day to day experience in Software Data, and Engineering.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

3 Common Practices That Won’t Change the Outcome of Your Project

Binary Tree: Insert in O(1) time, Delete, and Search

Clone & Migrate data Between Kubernetes Clusters with Velero

Permutation in Place

Spring AOP in 2021: level up your logging

ReactiveConf 2019: Building an all-inclusive software community

TryHackMe | The Server From Hell Write Up

Francium Protocol x IM community AMA RECAP

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tamir Suliman

Tamir Suliman

Writer, Engineer, Cyber security enthusiast ,PhD. Candidate & 4 Open Source write about my day to day experience in Software Data, and Engineering.

More from Medium

Notifications for failed cron jobs

Containers: In-depth Introduction

Configure Self-signed Server Certificate in git bash for a Particular HTTPS Remote.

How to run docker and docker-compose commands inside your Jenkins Container