Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Last active December 19, 2015 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PieterScheffers/9ea9e42c99d3ddd6437a to your computer and use it in GitHub Desktop.
Save PieterScheffers/9ea9e42c99d3ddd6437a to your computer and use it in GitHub Desktop.
Git create server
### Server ###
# create user
# become someuser
su someuser
# to home directory of someuser
cd ~
# create ssh keys
ssh-keygen -t rsa
# create subdirectory
mkdir sites && cd sites
# create bare git repo (/home/someuser/sites/somerepo.git)
git init --bare somerepo.git
### Client ###
# Copy client public key to authorized_keys file on server
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 2222 someuser@somehost
# add remote
# Can be a scp path --> path relative to the user folder, but no non-default port (22)
# Like: ssh://someuser@somehost:sites/somerepo.git
# Or an ssh path --> need absolute path, but can have a non-default port (22)
# Like ssh://someuser@somehost:2222/home/someuser/sites/somerepo.git
# or ssh://someuser@somehost:2222/~/sites/somerepo.git
git remote add production ssh://someuser@somehost:2222/~/sites/somerepo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment