Windows server 2012 配置完gogs,无法添加ssh


#1

在配置完gogs,准备添加ssh时,每当我要添加ssh。就报出以下异常信息:
An error has occurred : addKey: fail to parse public key: exec: “ssh-keygen”: executable file not found in %PATH% - exec: “ssh-keygen”: executable file not found in %PATH%

网上查找资料页无果,想来应该是个简单的错误,但我真的不清楚原因出在哪里,希望获得一点点帮忙!!!


#2

谷歌一搜就出来了,没装这个东西。。装个 git windows 套件全都有了


#3

你好,非常感谢您百忙之中的回答,我自己也会努力寻找答案。
但其实我正是因为已经安装了 git for windows 并且在cmd窗口查看到了版本号,而在gogs里添加报错。所以疑惑是不是有什么路径需要配置,而我不知道的。。:sweat_smile:


#4

你好,我发现问题所在了是因为环境变量path我配置在了的git的安装目录bin下。其实应该配置在git目录/usr/bin目录下。配置好后添加成功,但是出现新问题是,我使用内置ssh时,设置START_SSH_SERVER = true时,gogs启动不成功,gogs.log日志上也没有说明错误原因,因此产生了新的困惑。。。:thinking:


#5

凡出错必有日志,不是在 gogs.log 就是你系统启动的监管日志里。先尝试手动启动,能成功再用服务启动


#6

好的,谢谢,我自己再研究看看。


#7

gogs版本:0.11.66.0916
数据库:mysql
开启内置ssh,发现新的报错如下,请问是有什么配置没配好吗?

PS D:\Git\gogs> .\gogs.exe web
2018/12/10 20:14:01 [TRACE] Custom path: D:/Git/gogs/custom
2018/12/10 20:14:01 [TRACE] Log path: D:/Git/gogs/log
2018/12/10 20:14:01 [TRACE] Log Mode: Console (Trace)
2018/12/10 20:14:01 [TRACE] Log Mode: File (Trace)
2018/12/10 20:14:01 [ INFO] ZX 0.11.66.0916
2018/12/10 20:14:01 [ INFO] Cache Service Enabled
2018/12/10 20:14:01 [ INFO] Session Service Enabled
2018/12/10 20:14:01 [ INFO] Git Version: 2.19.2
2018/12/10 20:14:01 [ INFO] SQLite3 Supported
2018/12/10 20:14:01 [ INFO] Run Mode: Production
2018/12/10 20:14:01 [TRACE] Doing: CheckRepoStats
.\gogs.exe : panic: SSH: Fail to parse private key
所在位置 行:1 字符: 1
+ .\gogs.exe web
+ ~~~~~~~~~~~~~~
   + CategoryInfo          : NotSpecified: (panic: SSH: Fail to parse private key:String) [], RemoteException
   + FullyQualifiedErrorId : NativeCommandError

goroutine 1 [running]:
github.com/gogs/gogs/pkg/ssh.Listen(0xc042437511, 0x7, 0x16, 0xc04211c360, 0x6, 0x6)
   E:/Go/src/github.com/gogs/gogs/pkg/ssh/ssh.go:182 +0x3b5
github.com/gogs/gogs/routes.GlobalInit()
   E:/Go/src/github.com/gogs/gogs/routes/install.go:93 +0x234
github.com/gogs/gogs/cmd.runWeb(0xc0423f7040, 0x0, 0xfe)
   E:/Go/src/github.com/gogs/gogs/cmd/web.go:171 +0x71
github.com/gogs/gogs/vendor/github.com/urfave/cli.HandleAction(0xe542c0, 0xffae60, 0xc0423f7040, 0xc04222c500, 0x0)
   E:/Go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:483 +0xb4
github.com/gogs/gogs/vendor/github.com/urfave/cli.Command.Run(0xfa98ee, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfbc6e4, 0x10, 0x0, ...)
   E:/Go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/command.go:193 +0xa3c
github.com/gogs/gogs/vendor/github.com/urfave/cli.(*App).Run(0xc04229c4e0, 0xc042002420, 0x2, 0x2, 0x0, 0x0)
   E:/Go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:250 +0x707
main.main()
   E:/Go/src/github.com/gogs/gogs/gogs.go:40 +0x2bf

#8

这个问题 gtihub 上也有人报过了。。不过你是用的这个版本没有打印为什么失败,如果方便的话可以从 master 分支自行编译,或者暂时不使用 ssh 功能。


#9

初步怀疑可能是权限相关的问题,内置 ssh 服务器会生成一个文件默认在 data/ssh/gogs.rsa,这应该是一个有效的私钥,可能出于某种原因文件创建失败或者内容不完整


#10

非常抱歉,我并不怎么熟悉go语言,我的文件是成功的生成的,请问这样端格式是否可以看出错误?
密钥-gogs.rsa如下:

-----BEG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