You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clone and push to git repository test fixtures over HTTP.
4
+
Clone and push to git repository test fixtures over HTTP or SSH.
6
5
7
6
## What it does
8
7
@@ -22,6 +21,12 @@ It also supports HTTP Basic Auth password protection of repos so you can test ho
22
21
23
22
Using `isomorphic-git` and testing things from browsers? Fear not, `git-http-mock-server` includes appropriate CORS headers.
24
23
24
+
`git-ssh-mock-server` is similar, but because authentication happens before the client can say which repo
25
+
they are interested in, the authentication can't be customized per repository.
26
+
By default it allows anonymous SSH access. You can disable anonymous access and activate password authentication by setting the `GIT_SSH_MOCK_SERVER_PASSWORD` evironment variable.
27
+
(When password auth is activated, any username will work as long as the password matches the environment variable.)
28
+
Alternatively, you can set the `GIT_SSH_MOCK_SERVER_PUBKEY` environment variable to true to disable anonymous access and activate Public Key authentication. What key to use is explained in detail later in this document.
29
+
25
30
## How to use
26
31
27
32
```sh
@@ -34,14 +39,16 @@ Now `cd` to a directory in which you have some bare git repos and run this serve
If you don't have `htpasswd` on your machine, you can use [htpasswd](https://npm.im/htpasswd) which is
81
93
a cross-platform Node implementation of `htpasswd`.
82
94
95
+
### Public Key Auth support (ssh-only)
96
+
97
+
`git-ssh-mock-server` generates its own keypair using the system's native `ssh-keygen` the first time it's run,
98
+
in order to create encrypted SSH connections.
99
+
This key can be used to authenticate with the server as well!
100
+
101
+
1. Run `GIT_SSH_MOCK_SERVER_PUBKEY=true git-ssh-mock-server`
102
+
2. Try cloning (e.g. `git clone ssh://localhost:2222/imaginatively-named-repo.git`). It shouldn't work.
103
+
2. Run `git-ssh-mock-server exportKeys` which will copy the key files to `./id_rsa` and `./id_rsa.pub` in the working directory with the correct file permissions (`600`).
104
+
3. Run `ssh-add ./id_rsa`
105
+
4. Now try cloning. It works!
106
+
5. To clear the key from the ssh-agent, use `ssh-add -d ./id_rsa`
107
+
108
+
You can use `GIT_SSH_MOCK_SERVER_PUBKEY` and `GIT_SSH_MOCK_SERVER_PASSWORD` together, but using either one disables anonymous SSH access.
0 commit comments