Setup Local Git Server for Team


Few days ago I setup Git Local Server for my team and all of our repository are store locally and all of our team members push code to that.

I will write about Git Local server and SSH Password less access and then create local repository.

Note: This tutorial is only for LINUX & MAC users not for WINDOWS users.

Our first step is to create new user for git server computer. (This step is optional and you can use your default user account).

LINUX:  Create LINUX User Account

MAC:  Create MAC User Account

If you are creating git server on MAC then you also need to allow remote user login. You can check guide here: Mac Remote Login Access

Step 1: SSH Passwordless Login using SSH Keygen

SSH (Secure SHELL) is an open source and most trusted network protocol that is used to login into remote servers for execution of commands and programs. It is also used to transfer files from one computer to another computer over the network using secure copy (SCP) Protocol.

In this article I will show you how to setup password-less login on MAC/Linux using ssh keys to connect to remote Linux or MAC servers without entering password.

Example Server & Client Details. 

SSH Remote Host (Server) : 
SSH Client :

Our server IP is and client IP is 192.168.012

Server Computer Username: git

Client Computer Username: tanseer

Step 1-a) Create Authentication SSH-Kegen Keys on Client – (

Login to your Client Computer which IP is and run following command in Terminal:

[tanseer@ ~]$ ssh-keygen -t rsa

This command will generate a pair of public keys.  You will see something like this and also press enter when it ask.

Generating public/private rsa key pair.
Enter file in which to save the key (/home/tanseer/.ssh/id_rsa): [Press enter key]
Created directory '/home/tanseer/.ssh'.
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/tanseer/.ssh/id_rsa.
Your public key has been saved in /home/tanseer/.ssh/
The key fingerprint is:
5f:ad:40:00:8a:d1:9b:99:b3:b0:f8:08:99:c3:ed:d3 tanseer@.....
The key's randomart image is:
+--[ RSA 2048]----+
|        ..oooE.++|
|         o. o.o  |
|          ..   . |
|         o  . . o|
|        S .  . + |
|       . .    . o|
|      . o o    ..|
|       + +       |
|        +.       |

Step 1-b) Create .ssh Directory on Server from client

Using SSH from client ( to connect wither server ( and create .ssh directory under it, using following command.

[tanseer@ ~]$ ssh git@ mkdir -p .ssh

You will see following output after running above command:

The authenticity of host ' (' can't be established.
RSA key fingerprint is 45:0e:28:11:d6:81:62:16:04:3f:db:38:02:la:22:4e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
git@'s password: [Enter Your Password Here]

Step 1-c) Upload Generated Public Keys to Server

Use SSH from client and upload new generated public key ( on server under git‘s .ssh directory as a file name authorized_keys. Use following command:

[tanseer@ ~]$ cat .ssh/ | ssh git@ 'cat >> .ssh/authorized_keys'

You will see following output:

git@'s password: [Enter Your Password Here]

Step 1-d) Set Permissions on Server

Due to different SSH versions on servers, we need to set permissions on .ssh directory and authorized_keys file. Run following command:

[tanseer@ ~]$ ssh git@ "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

You will see following output:

git@'s password: [Enter Your Password Here]

Now you have created SSH Passwordless Login and to test this just connect to your server from client using following command:

[tanseer@ ~]$ ssh git@

This will connect you to server. If it works fine then just exit from server in your terminal using following command:

[git@ ~]$ exit

Above command will close connection to server.

Step 2: Create Repository on Server

Login to your Server ( and run following command to create repository.

 [git@]$ git init –bare project1.git

In above command we create bare repository on our server which mean that this repository has no working tree. It means its whole contents is what you have in .git directory. You can only commit to bare repository by pushing to it from your local clone from client. It has no working tree, so it has no files modified, no changes.

Step 3: Clone Repository from Server

Now login to your client computer and clone repository from server we created in previous step. Using following command on your client computer:

[tanseer@]$ git clone ssh://git@<path_on_server>/<repository_name>.git

Replace path_on_server and repository_name with your desired path and repository name.


[tanseer@]$ git clone ssh://git@

That’s it you have created Local Git Server and clone it repository and now you can add, commit and push your code to local repository using git commands.

If you have issue or questions then ask it in comment, I will answer it.

Leave a Reply

Read previous post:
Mac Remote Login Access

For devices using the same macOS, you can allow remote Mac login using a Secure Shell (SSH). This enables Mac...