Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshnuss/git-ssh-server
A small git/ssh server for hosting repos
https://github.com/joshnuss/git-ssh-server
git hosting node ssh
Last synced: 25 days ago
JSON representation
A small git/ssh server for hosting repos
- Host: GitHub
- URL: https://github.com/joshnuss/git-ssh-server
- Owner: joshnuss
- Created: 2020-05-21T00:06:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-21T17:05:58.000Z (about 3 years ago)
- Last Synced: 2024-04-14T03:14:18.930Z (7 months ago)
- Topics: git, hosting, node, ssh
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Example GIT+SSH Server
----------------------A small git/ssh server for hosting repos and running custom logic after push.
# Features
- `git push`, `git pull` & `git clone` are supported.
- Authentication is done via public keys exclusively. (no passwords allowed)
- Repos & public keys are stored on disk.
- Repos are automatically created on-demand (first push).
- Server-side hooks like `pre-receive`, `update` & `post-receive` can be applied to all repos.## Setup
Get the latest code:
```bash
git clone joshnuss/git-ssh-server
cd git-ssh-server
yarn
```Create a host key with a passphrase:
```bash
ssh-keygen host.key
```Add `.pub` public keys to the `keys` folder:
```bash
# if using locally
cp ~/.ssh/id_rsa.pub keys/me.pub
```Add git hooks like `pre-receive`, `update` & `post-receive` to the `hooks` folder (optional).
Example `post-receive` hook:
```bash
#!/bin/bashwhile read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to production..."
git --work-tree=/var/www/html --git-dir=/home/demo/proj checkout -f
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
```Hooks are symlinked on first push.
## Usage
Start the server:
```bash
PORT=22755 ADDRESS=localhost PASSPHRASE=foobar yarn start
```For an existing repo:
```bash
# add a remote
git remote add hosting ssh://git@localhost:22755/your-repo-name# OR if you're using a standard SSH port 22
git remote add hosting [email protected]/your-repo-name# push to remote
git push hosting master# pull from remote
git pull hosting master
```Or clone a new repo:
```bash
# clone from remote
git clone ssh://[email protected]:22755/your-repo-name# OR if using standard SSH port 22
git clone [email protected]/your-repo-name
```## License
MIT