Issue
PR #942 add feature to add repo url to known host, but it only parse the host and did not parse the port when running ssh-keyscan command. This make the known host added for port 22 instead.
My use case is using self hosted gitea/forgejo, because port 22 already used by the host for ssh into the host machine I use port 2222 instead for the git ssh. The repo URL is something like this:
ssh://git@forgejo.domain.tld:2222/LazyGeniusMan/test-repo.git
The current parsing is :
|
SSH_HOST=$(echo "$REPO_URL" | sed -E 's|^(ssh://)?([^@/]+@)?([^:/]+).*|\3|') |
The result for repo URL above is : forgejo@domain.tld
Then the value used in:
|
if KNOWN_HOST_ENTRY=$(ssh-keyscan -H -t rsa,ecdsa,ed25519 "$SSH_HOST" 2> /dev/null) && [ -n "$KNOWN_HOST_ENTRY" ]; then |
Proposed Fix
- Parse the port from ssh repo url
- Pass the
-p arg to ssh-keyscan command
Issue
PR #942 add feature to add repo url to known host, but it only parse the host and did not parse the port when running
ssh-keyscancommand. This make the known host added for port 22 instead.My use case is using self hosted gitea/forgejo, because port 22 already used by the host for ssh into the host machine I use port 2222 instead for the git ssh. The repo URL is something like this:
The current parsing is :
registry/registry/coder/modules/git-clone/run.sh
Line 56 in 6be121e
The result for repo URL above is :
forgejo@domain.tldThen the value used in:
registry/registry/coder/modules/git-clone/run.sh
Line 64 in 6be121e
Proposed Fix
-parg tossh-keyscancommand