- Gitea version (or commit ref): 1.11.3
- Git version: 2.22.0.windows.1
- Operating system: Windows Server 2019
- Database (use
[x]):
- Can you reproduce the bug at https://try.gitea.io:
- Log gist:
Description
gitea doesn't work on Windows with OpenSSH (not in-built ssh server). The problem is with the single quotes with the command in authorized_keys:
command="C:/Gitea/gitea.exe --config='C:/Gitea/custom/conf/app.ini' serv key-1"
When I run this command on Windows (without any ssh in the picture) we get the following debug output:
2020/03/25 09:36:43 ...s/setting/setting.go:531:NewContext() [W] Custom config 'C:/Gitea/custom/'C:/Gitea/custom/conf/app.ini'' not found, ignore this if you're running first time 2020/03/25 09:36:43 ...s/setting/setting.go:785:NewContext() [F] failed to create 'C:/Gitea/custom/'C:/Gitea/custom/conf/app.ini'': mkdir C:\Gitea\custom'C:: The filename, directory name, or volume label syntax is incorrect.`
There are two problems:
- The single quotes around the --config file cause gitea on Windows to report that it cannot find the file.
- gitea then goes ahead and tries to create "C:/Gitea/custom/'C:/Gitea/custom/conf/app.ini''. This is an invalid path and gitea aborts.
The quick fix which works for me is to manually change the command in authorized_keys to:
command="C:/Gitea/gitea.exe --config=\"C:/Gitea/custom/conf/app.ini\" serv key-1"
With double quotes I can now use gitea over OpenSSH (not build-in ssh) on Windows. The problem now is that authorized_keys will be overwritten next time we create a user for example.
To fix I believe what needs to be done:
- Change gitea to output double quotes in authorized_keys, or
- Figure out why single quotes don't work (perhaps a go problem?)
- Fix gitea's parsing of argv[0] so it can handle 'C:/...'
I also question why gitea would ever be creating a template app.ini when invoked with the serv command. That doesn't seem like the right thing to do.
[x]):Description
gitea doesn't work on Windows with OpenSSH (not in-built ssh server). The problem is with the single quotes with the command in authorized_keys:
When I run this command on Windows (without any ssh in the picture) we get the following debug output:
2020/03/2509:36:43 ...s/setting/setting.go:531:NewContext() [W] Custom config 'C:/Gitea/custom/'C:/Gitea/custom/conf/app.ini'' not found, ignore this if you're running first time2020/03/25 09:36:43 ...s/setting/setting.go:785:NewContext() [F] failed to create 'C:/Gitea/custom/'C:/Gitea/custom/conf/app.ini'': mkdir C:\Gitea\custom'C:: The filename, directory name, or volume label syntax is incorrect.`There are two problems:
The quick fix which works for me is to manually change the command in authorized_keys to:
With double quotes I can now use gitea over OpenSSH (not build-in ssh) on Windows. The problem now is that authorized_keys will be overwritten next time we create a user for example.
To fix I believe what needs to be done:
I also question why gitea would ever be creating a template app.ini when invoked with the serv command. That doesn't seem like the right thing to do.