git - setting up a remote revision control server on a SmartOS Instance

Jasun -

The following is how you can set up a git repository on a SmartOS Instance and access it via SSH from client

It is highly recommended that anything you do with your app - from code to config files - be in revision control.

This is the first step to automation and provides backup and rollback.

  1. Provision a 512M SmartOS SmartMachine

  2. SSH into to the new SmartMachine as root

  3. Install git via the command: pkgin

    pkgin in scmgit
  4. Create git user

    groupadd git
    mkdir -p /home/git/.ssh
    touch /home/git/.ssh/authorized_keys
    chmod 600 /home/git/.ssh/authorized_keys
    useradd -g git -d /home/git -s /usr/bin/bash git
    chown -R git:git /home/git
    passwd git
  5. Configure git user account

    You will need to switch to the git user with the command

    su - git

    Then configure the git user's account

    ssh-keygen -t dsa -b 4096
    env > ~/.ssh/environment
  6. Still as the git user copy any public SSH keys from remote systems that will access the git repository to:

  7. Create git repository

    It is highly recommended that you keep your git repositories on a NFS mount. The following examples are for creating a git repo on a NFS mount.

    Make sure your NFS share is mounted to /shared

    As the user root:

    mkdir -p /shared/git
    chown -R git:git /shared/git

    As the git user ( you will have to su - git )

    mkdir /shared/git/foo.git
    cd /shared/git/foo.git
    git --bare init

    git config --global ""
    git config --global "git Admin"

    git remote add origin git@
    git push origin master

  8. On the remote client you ca n now connect to your git repo with:

    git clone ssh://git@<git_server_IP>/shared/git/foo.git

Now you have a git repository set up. To test it out you can do the following from the remote system:

Change directory to the git clone you just made and create a simple test file called: bar.txt

On the command line of the remote client you can commit the new file to the repo with the commands:

git add bar.txt 
git commit -am "Test file add"
git push origin master
Have more questions? Submit a request


  • 0
    Paul Serby

    Why do you say 'It is highly recommended that you keep your git repositories on a NFS mount.' ? 

  • 0

    Hi Paul,


    This will prevent a git repo from getting destroyed should something happen to the SM running your git repo.  This is more of a way building in a backup for your git repo.

Article is closed for comments.