Allowing multiple users to pull from a git repository on a shared server

A pretty common situation. Multiple developers working together on their local development machines and connecting to a central git repository with their own credentials. And there’s a dev/staging server where all users need to to have access to go login and pull the code. When you clone the git repository on the server, it essentially sets it up as the user who set it up and doesn’t allow other users to pull the code. Here’s how the config looks like:

        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = ssh://
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "dev"]
        remote = origin
        merge = refs/heads/dev
[branch "task/upgrading_django"]
        remote = origin
        merge = refs/heads/task/upgrading_django

And the user can pull the repository using git pull

Now, in order to configure the repository so that all users who have access to the server are able to pull the code, here’s how the configuration should look like:

        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url =
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "dev"]
        remote = origin
        merge = refs/heads/dev
[branch "task/upgrading_django"]
        remote = origin
        merge = refs/heads/task/upgrading_django
[remote "varun.verma"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url =
[remote "other.user"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url =

And pull the repository by executing sudo git pull varun.verma task/upgrading_django. The system would ask for your local server password to sudo followed by the password for the remote git repository. This should resolve the problem.

Divide files into folders and zip them

I have a set of files that I usually have to divide into multiple folders and zip them together so I can upload on the cloud. It’s been a long time I’ve been manually doing this but then I thought I’d rather automate this altogether. So now all I have to do is calculate how many folders I need and a prefix for the folder, e.g. Color or BW and the program does the rest for me. It creates the folders, equally divides the files into those folders and zip them. Once the program finishes execution, I’m ready to upload them.


# Enter number of folders to be created
# The program will create those folders and divide and move the files equally within those folders

# Exit if number of folders not provided
if [[ $1 -eq 0 ]]; then
	echo 'Enter number of folders to be created'
	exit 0

# Exit if folder_previx is not provided
if [[ $2 = '' ]]; then
	echo 'Enter the prefix for the folder, e.g. Color or BW'
	exit 0

# Get total number of files in directory
file_count=`ls -lrt *.jpg | wc -l`
echo Total files: $file_count

files_per_folder=$((file_count / num_folders))
echo Files per folder: $files_per_folder

# Create folders; Divide and move images to folders and zip them so they are ready to upload
for ((i=1; i<=$num_folders; i++)); do
	if [[ $i -lt 10 ]]; then
		mkdir $2-Part0$i
		find . -name "*.jpg" -maxdepth 1 -type f | head -$files_per_folder | xargs -I{} mv {} $2-Part0$i
		zip -r $2-Part0$ $2-Part0$i
		mkdir $2-Part$i
		find . -name "*.jpg" -maxdepth 1 -type f | head -$files_per_folder | xargs -I{} mv {} $2-Part$i
		zip -r $2-Part$ $2-Part$i

Executing psql from command prompt on Mac OSX after installing PostgreSQL

I installed PostgreSQL but wasn’t able to execute psql on the command prompt to execute queries. I had to add the PostgreSQL path to the PATH variable in order to do that. It’s best to append the path in the bash_profile so it’s ready and available every time the shell loads. Add the following lines (depending on the location of your PostgreSQL version)

# Modify PATH
export PATH=$PATH:/Library/PostgreSQL/9.5/bin

Mac – Update openssl

I had a hard time updating openssl on my Mac OSX. Here’s what I did to update the libraries:

Install and upate brew

brew update
brew install openssl
brew link --force openssl

openssl version

If one of the bad versions come up (1.0.1a-f), you can figure out which version of openssl you’re using, this way:

which openssl

Often this is from /usr/bin. To make sure you get the updated version, drop a symlink into /usr/local/bin to point to the updated openssl, like this:

ln -s /usr/local/Cellar/openssl/1.0.1g/bin/openssl /usr/local/bin/openssl

Note: You may have to exit and start the Terminal session to see the new changes.

As an alternative to that final step, some people replace the openssl in /usr/bin with a symlink to /usr/local/Cellar/openssl/1.0.1g/bin/openssl (or whatever your version is):

mv /usr/bin/openssl /usr/bin/openssl_OLD
ln -s /usr/local/Cellar/openssl/1.0.1g/bin/openssl /usr/bin/openssl

But this is known to cause problems with some more recent versions of OSX. Better to just insert a new symlink into /usr/local/bin, which should take precedence on your path over /usr/bin.

Original article:

Configure Static IP on CentOS

## Configure eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

NAME="System eth0"

## Configure Default Gateway
# vi /etc/sysconfig/network


## Restart Network Interface

/etc/init.d/network restart

## Configure DNS Server
# vi /etc/resolv.conf

nameserver      # Replace with your nameserver ip
nameserver # Replace with your nameserver ip

Debian – Change Hostname

Step 1: Edit /etc/hostname with the new name
Step 2: Edit /etc/hosts with the new name
Step 3: Reboot machine (shutdown -r now)

Find openssl and TLS protocol version

To get the version of OpenSSL installed on the OS:

$ openssl version
OpenSSL 1.0.1t  3 May 2016

To get the TLS/SSL protocol version, establish a secure connection to any of the servers on the web and the session information would have details of the Protocol.

$ openssl s_client -connect
depth=3 C = US, O = Equifax, OU = Equifax Secure Certificate Authority
verify return:1
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = Google Inc, CN = Google Internet Authority G2
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN =
verify return:1
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/
   i:/C=US/O=Google Inc/CN=Google Internet Authority G2
 1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
   i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
 2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
   i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
Server certificate
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/
issuer=/C=US/O=Google Inc/CN=Google Internet Authority G2
No client certificate CA names sent
SSL handshake has read 3727 bytes and written 415 bytes
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
    Session-ID: 519CA9ADE744B72A3E428105172579761A0E104E100CD11BA496497D4769E487
    Master-Key: BEE6BD732D3D48B68FD96C37BD0A072B3A31C78253CDBA0F623D9DB0FCE5D06F9DC13AD298EE48922B85D824FCE35C74
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 100800 (seconds)
    TLS session ticket:
    0000 - fa 11 30 4d e2 45 8a a8-34 3b a5 b4 cd 1e c6 0a   ..0M.E..4;......
    0010 - ed 1e 03 d6 66 fb 83 c7-fb c5 ac e6 eb 69 2f c2   ....f........i/.
    0020 - 72 8f 38 a0 ba 1b 9b f5-34 70 63 6d 36 db 0a 0f   r.8.....4pcm6...
    0030 - 32 38 d9 03 df 10 78 2a-66 22 e5 eb c2 c4 c1 44   28....x*f".....D
    0040 - eb 36 ab d5 05 ed 54 20-37 8b b1 a8 2f 9a 2f ae   .6....T 7..././.
    0050 - 00 30 48 36 58 4c 80 1f-38 5c b9 da b3 85 8e f7   .0H6XL..8\......
    0060 - c8 dd 59 00 5c e8 ad 5e-7b 1d e7 1d e0 a2 ee 4b   ..Y.\..^{......K
    0070 - ec 5b d7 08 b0 24 1e a2-1a fd 47 74 b1 8b 1b b7   .[...$....Gt....
    0080 - 55 dd 01 c5 c7 29 fb f4-ec f3 88 27 d2 93 8c 32   U....).....'...2
    0090 - 7b e2 1b 54 b8 22 bf 90-f0 63 5c 46 14 9f a8 ad   {..T."...c\F....
    00a0 - 7b 5d 51 1d                                       {]Q.

    Start Time: 1473883627
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)