The SSH URL with port display is incorrect #11445

Closed
opened 2025-11-02 09:37:54 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @Gsonovb on GitHub (Aug 12, 2023).

Description

Hi,

I found a SSH URL showing error, that the port number is display the username (or organization name).

I found this code location here ,and lost publish SSH PORT

If the USE_COMPAT_SSH_URI=true setting is turned on, it is displayed correctly

Screenshots

giteabug

Gitea Version

1.20.2

Can you reproduce the bug on the Gitea demo site?

No

Operating System

Debian with docker

Browser Version

EDGE

Originally created by @Gsonovb on GitHub (Aug 12, 2023). ### Description Hi, I found a SSH URL showing error, that the port number is display the username (or organization name). I found this code location [here](https://github.com/go-gitea/gitea/blob/v1.20.2/models/repo/repo.go#L562C7-L562C7) ,and lost **publish SSH PORT** If the `USE_COMPAT_SSH_URI=true` setting is turned on, it is displayed correctly ### Screenshots ![giteabug](https://github.com/go-gitea/gitea/assets/3164300/a9ce0966-c1c9-42a1-ab5f-55574652a8c3) ### Gitea Version 1.20.2 ### Can you reproduce the bug on the Gitea demo site? No ### Operating System Debian with docker ### Browser Version EDGE
GiteaMirror added the topic/uitype/bug labels 2025-11-02 09:37:54 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Aug 12, 2023):

22 is the default SSH port so 22 can always be omitted

@wxiaoguang commented on GitHub (Aug 12, 2023): 22 is the default SSH port so 22 can always be omitted
Author
Owner

@silverwind commented on GitHub (Aug 12, 2023):

I see nothing wrong here ssh:// implies port 22. Just like https:// implies port 443. You wouldn't write :443 for HTTPS for example, so we don't need it for SSH either.

@silverwind commented on GitHub (Aug 12, 2023): I see nothing wrong here `ssh://` implies port 22. Just like `https://` implies port 443. You wouldn't write `:443` for HTTPS for example, so we don't need it for SSH either.
Author
Owner

@Gsonovb commented on GitHub (Aug 13, 2023):

@wxiaoguang @silverwind

If the USE_COMPAT_SSH_URI=true setting is turned on, it is displayed correctly
but,
USE_COMPAT_SSH_URI=false , then show git.homwork.local [:22] /GWork/XXX

BUT Here is
git.homework.local [: GWork] /XXX
, that Gwork is Port Number, XXX is Username

git can't connent git.homework.local with GWork Port!!

code:https://github.com/go-gitea/gitea/blob/v1.20.2/models/repo/repo.go#L562C7-L562C7

	if setting.Repository.UseCompatSSHURI {             <<<< - HERE IS  omitted!!!!
		return fmt.Sprintf("ssh://%s@%s/%s/%s.git", sshUser, sshDomain, url.PathEscape(ownerName), url.PathEscape(repoName))
	}
      
	return fmt.Sprintf("%s@%s:%s/%s.git", sshUser, sshDomain, url.PathEscape(ownerName), url.PathEscape(repoName))
                                             ^^^^ HERE IS LOST SSH  PORT ,IS PASS ownerName!!

``
@Gsonovb commented on GitHub (Aug 13, 2023): @wxiaoguang @silverwind If the `USE_COMPAT_SSH_URI=true` setting is turned on, it is displayed correctly but, `USE_COMPAT_SSH_URI=false` , then show `git.homwork.local [:22] /GWork/XXX` **BUT** Here is ```git.homework.local [: GWork] /XXX``` , that **Gwork** is Port Number, XXX is Username git can't connent **git.homework.local** with **GWork** Port!! code:https://github.com/go-gitea/gitea/blob/v1.20.2/models/repo/repo.go#L562C7-L562C7 ``` if setting.Repository.UseCompatSSHURI { <<<< - HERE IS omitted!!!! return fmt.Sprintf("ssh://%s@%s/%s/%s.git", sshUser, sshDomain, url.PathEscape(ownerName), url.PathEscape(repoName)) } return fmt.Sprintf("%s@%s:%s/%s.git", sshUser, sshDomain, url.PathEscape(ownerName), url.PathEscape(repoName)) ^^^^ HERE IS LOST SSH PORT ,IS PASS ownerName!! ``
Author
Owner

@wxiaoguang commented on GitHub (Aug 13, 2023):

https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols

scp-like syntax for the SSH protocol: git clone [user@]server:project.git

image
@wxiaoguang commented on GitHub (Aug 13, 2023): https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols `scp-like syntax for the SSH protocol`: `git clone [user@]server:project.git` <img width="698" alt="image" src="https://github.com/go-gitea/gitea/assets/2114189/6f14196c-2c28-4ec2-a6a8-70e041469c8d">
Author
Owner

@Gsonovb commented on GitHub (Aug 14, 2023):

@wxiaoguang

OK , I see.

it might indeed be a bit more troublesome.

I'm use vscode and it recognize that URL as an HTTP address.

@Gsonovb commented on GitHub (Aug 14, 2023): @wxiaoguang OK , I see. it might indeed be a bit more troublesome. I'm use vscode and it recognize that URL as an HTTP address.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11445