Skip to content

Generated authorized_keys does not work on Windows #10813

@richard-browne

Description

@richard-browne
  • Gitea version (or commit ref): 1.11.3
  • Git version: 2.22.0.windows.1
  • Operating system: Windows Server 2019
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • 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:

  1. The single quotes around the --config file cause gitea on Windows to report that it cannot find the file.
  2. 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:

  1. Change gitea to output double quotes in authorized_keys, or
  2. Figure out why single quotes don't work (perhaps a go problem?)
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions