godot-git-plugin icon indicating copy to clipboard operation
godot-git-plugin copied to clipboard

Add an option to specify a custom SSH port

Open Cwavs opened this issue 1 year ago • 2 comments

Hi! Enjoying the plugin so far, besides a few snags like no signing not a biggie, saw the other issue about it, and I don't mind committing from the command line.

On a similar note however, my repo is hosted on a forgejo instance on which ssh is running on a non-standard port (2221) so as to not interfere with other services running on the same host.

As far as I can see there is no way to configure the SSH port used by the plugin. As a result currently the plugin is serving as more of a window into my git repo's current state (still very useful) rather than letting me perform git operations without leaving Godot, but I do understand this is a work in progress.

Again this isn't a big deal for me, I'm already committing in the CLI so I may as just do my git operations there too.

Cwavs avatar Apr 11 '25 17:04 Cwavs

Shouldn't the custom SSH port be part of the remote address (e.g. [[email protected]:2221]:user/repo.git) ? How do other Git clients typically handle this?

Calinou avatar Apr 17 '25 13:04 Calinou

Sorry for the late reply, I've been away from my PC for the past few days.

I've done some testing, and this does seem to work for normal git (though I personally have two SSH configs as I find it easier to use), but Godot doesn't seem to respect that, or at least I haven't been able to get it to pull or push as it prints one of two errors. One would seems to point towards it not finding a valid SSH server (this appears when I try to specify the port in the git config):

ERROR: core/variant/variant_utility.cpp:1098 - GitPlugin: Could not connect to remote "origin". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password. Error -16: Failed to retrieve list of SSH authentication methods: Failed getting response in godot-git-plugin/src/git_plugin.cpp:_pull#L435

The other appears when I don't specify the port in the git config, and seems to suggest to me it's trying to reach port 22 and is being rejected as it has the incorrect SSH config.

ERROR: core/variant/variant_utility.cpp:1098 - GitPlugin: Could not connect to remote "origin". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password. Error -1: failed to connect to {My Forgejo IP Address}: Connection refused in godot-git-plugin/src/git_plugin.cpp:_pull#L435

The normal git CLI seems to work find in both these situations.

Considering that the client explicitly asks for the SSH keys and username, I'm unsure how much it pulls from the git/ssh config itself, and I think the approach the plugin currently takes of pulling some options from the config and having the user input others may be confusing me so if I'm doing some thing wrong feel free to correct me.

I'm not sure how other git clients deal with custom ports as I don't really use them, but I wouldn't be surprised if they pulled it from the git config or had their own inputs (and potentially write that back to the git config), or maybe even bypass the issue entirely by just calling the git CLI under the hood. I'm not sure which approach, if any of those suit this plugin.

That said what I do may be slightly unorthodox, but as mentioned earlier I have two SSH configs, I then explicitly tell git to use the git one with the sshCommand option, e.g sshCommand = ssh -F ~/.ssh/config_git conceptually I find this easier, however it may not be the most typical set up, so if I have to forgo that I would be fine. Thanks again for the plugin!

Cwavs avatar Apr 19 '25 10:04 Cwavs