requarks / wiki

Wiki.js | A modern and powerful wiki app built on Node.js
https://js.wiki
GNU Affero General Public License v3.0
24.24k stars 2.68k forks source link

GitHub deployment key fails to push with SSH #555

Closed jasonsturges closed 6 years ago

jasonsturges commented 6 years ago

Actual behavior

My GitHub deployment is not operational, seemingly suffering from a variety of issues after following the Wiki.js documentation recommended way to integrate with GitHub using deployment keys.

On my Mac, I followed GitHub documentation to generate a SSH key:

ssh-keygen -t rsa -b 4096 -C "jason@jasonsturges.com"

No passcode was provided.

That public id_rsa.pub file was loaded to my GitHub repo's deployment keys

image

My Wiki.js config.yml specifies git:

git:
  url: https://github.com/jasonsturges/wiki.jasonsturges.com
  branch: master
  auth:
    type: ssh
    privateKey: /etc/wiki/keys/id_rsa
    sslVerify: true
  signature:
    name: Jason Sturges
    email: jason@jasonsturges.com

My Wiki.js docker-compose.yml links the private id_rsa key:

    volumes:
      - ./wiki-config.yml:/var/wiki/config.yml
      - ./id_rsa:/etc/wiki/keys/id_rsa

Wiki.js pulls the repo, and loads correct; however, is unable to push changes.

In the /logs/wiki-stderr.log, I see:

2018-06-22T20:40:01.113Z - error: [AGENT] Unable to push changes to remote Git repository!
2018-06-22T20:40:01.114Z - error: [AGENT] One or more jobs have failed:  
{ code: 128,
  message: '`git --git-dir=repo/.git --work-tree=repo push origin master` failed with code 128',
  stderr: 'fatal: could not read Password for \'https://jasonsturges@github.com\': No such device or address\n',
  stdout: '' }

If I enter the container as $ docker-compose exec wikijs /bin/bash and try to push the repo, I see

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

Even after I $ git push -u origin master the local Wiki.js repo is not pushing to GitHub remote.

What am I missing about this? Trying combos others have cited here haven't worked either, such as user@github or including the repo.git in the url.

Expected behavior

Wiki.js is able to push to GitHub using deployment keys.

Steps to reproduce the behavior

  1. Create a GitHub repo with initial commit
  2. Add deployment public key to GitHub repo
  3. Add private key to Wiki.js
NGPixel commented 6 years ago

The url param of your config is not a valid value for SSH auth. It must be in the following format: git@server.com:org/repo.git

https://docs.requarks.io/wiki/install/installation/git#using-ssh

jasonsturges commented 6 years ago

Sorry I missed that in the documentation - this works perfectly now, thanks.

git:
  url: git@github.com:jasonsturges/wiki.jasonsturges.com.git
  branch: master
  auth:
    type: ssh
    privateKey: /etc/wiki/keys/id_rsa
    sslVerify: true
  signature:
    name: Jason Sturges
    email: jason@jasonsturges.com