synology git管理程序添加

synology商店中默认支持gitlab; 奈何它最少要求4g内存; 2g内存苦逼的只能另求出路了;

推荐一https://hub.docker.com/r/jacekkow/gitblit 这个东东;

使用docker命令如下能够很方便的安装起来

docker run -d --name=gitblit \
-p {本机端口a}:{docker端口 8080} -p {本机端口b}:{docker端口8443} \
-p {本机端口c}:{docker端口9418} -p {本机端口d}:{docker端口29418} \
-v {本机映射目录}:/opt/gitblit-data \
jacekkow/gitblit

 

然后通过本机端口a既能够访问服务了; 默认登录的用户名密码 admin/admin

 

接下来给gitblit开启https

  1. $ sudo docker ps  
  2. $ sudo docker exec -it 775c7c9ee1e1 /bin/bash 

通过如上docker命令能够进入到一个docker容器中去;

根据gitblit官网提供的信息,https设置方式如下

http://www.gitblit.com/setup_go.html

NOTE: The Gitblit Authority is a GUI tool and will require X11 forwarding on headless UNIX boxes.

  1. authority.cmd or java -jar authority.jar --baseFolder data
  2. Click the new ssl certificate button (red rosette in the toolbar in upper left of window)
  3. Enter the hostname or ip address
  4. Make sure the checkbox serve https with this certificate is checked
  5. In the keystore password prompt, enter the server.storePassword password

 很遗憾,根据note这个对synology不适用;

所以当前只能通过访问https端口加上本地安装证书的方式暂时的支持https先了;

曲线救国,下载http://101.110.118.47/dl.bintray.com/gitblit/releases/gitblit-1.8.0.zip 同版本的windows版本,使用它的证书编辑器;

java -cp gitblit.jar com.gitblit.authority.Launcher --baseFolder {gitblit data所在目录};即可添加证书;

 

这时候输入对应的ip:port即可添加非localhost证书了;

 

那么添加合法证书怎么添加呢; 我猜测直接替换证书的操作也是可以的;

DSM ->安全性->导出证书;导出pem格式的证书,我们使用openssl.exe转换成cer和p12

"c:\Program Files\Git\mingw64\bin\openssl.exe" x509 -inform PEM -in cert.pem -outform DER -out ca.cer

管理员下运行 "c:\Program Files\Git\mingw64\bin\openssl.exe" pkcs12 -export -out caKeyStore.p12 -in cert.pem -inkey privkey.pem

转换成p12

接下操作参考https://stackoverflow.com/questions/29844572/gitblit-certificate-import

Okay so I figured it out now...

I destroyed my keystore upon attempting to import the certificate, this was the main problem that caused the crash.

First, I had to return to the default setup of certificates. I deleted both, data/serverKeyStore.jks and data/serverTrustStore, and launched gitblit again. The certificate creation failed...

I downloaded the gitblit for windows and ran authority.cmd to copy over the fresh files mentioned above to my debian system and voilà: gitblit started again with the default localhost certificate.

Now to import my certificate, I created a new keystore pkcs keystore containing my private key and certificate. Then, I ran:

keytool -importkeystore -srckeystore yourkeystore.p12 -srcstoretype pkcs12 -destkeystore serverKeyStore.jks

to import the keystore into the gitblit store. keytool -list listed both certificates along with their aliases.

Finally, I defined my certificate alias in data/gitblit.properties and the server ran.

具体操作如下; 导入证书,并查看证书,

keytool -importkeystore -srckeystore /certs/caKeyStore.p12 -srcstoretype pkcs12 -destkeystore serverKeyStore.jks

keytool -list -destkeystore serverKeyStore.jks

修改data/gitblit.properties,使证书生效;重启gitblit

 

posted @ 2018-12-18 23:32  Alcc  阅读(629)  评论(0编辑  收藏  举报