Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caddy-git unable to clone repos with non-standard port URL #76

Open
gganeshan opened this issue Sep 7, 2017 · 13 comments
Open

caddy-git unable to clone repos with non-standard port URL #76

gganeshan opened this issue Sep 7, 2017 · 13 comments
Labels

Comments

@gganeshan
Copy link

gganeshan commented Sep 7, 2017

caddy-git plugin is no longer able to clone repos with non-standard port URL. This was working a few weeks back and could have been introduced by this change

git {
        repo        ssh://[email protected]:7999/project/repo.git
        key         ~/.ssh/id_rsa
}

Multiple issues:

  • By default, the plugin tries to connect at port 22.

error

Activating privacy features... done.
Cloning into '/var/www'...
ssh: connect to host stash.abc.net port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
2017/09/07 15:19:58 exit status 128
  • If the port is specified in ~/.ssh/cong then it is able to connect to the server but still cannot clone the repo

ssh config

Host stash.abc.net
    StrictHostKeyChecking no
    port 7999

error

Activating privacy features... done.
Cloning into '/var/www'...
Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I tried the workaround suggested here but it did not work for me.

Note: I am able to clone the same URL manually.

@abiosoft abiosoft added the bug label Sep 7, 2017
@gganeshan
Copy link
Author

Guess, the git command being run by the plugin is:

git clone ssh://[email protected]/7999/project/repo.git
Cloning into 'repo'...
Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

👀 how :7999 got converted to /7999

@gganeshan
Copy link
Author

Disregard the above comment. It was just a guess 😞 .

@abiosoft
Copy link
Owner

abiosoft commented Sep 7, 2017

Let me get this right, what is the log output.
Is :7999 converted to /7999 ?

@gganeshan
Copy link
Author

Let me get this right, what is the log output.
Is :7999 converted to /7999 ?

This was just a guess.
The log output is not verbose enough to determine the URL being used.

@gganeshan
Copy link
Author

@abiosoft any updates on this issue??
Were you able to recreate it??

@mdcollins05
Copy link

mdcollins05 commented Sep 22, 2017

I'm having the same issue where the port is being ignored and not passed to ssh-keyscan as an argument and when it attempts to clone it tries to connect on port 22 regardless of the actual setting.

It was working in the past but now it stopped when I updated on Sept 11th.

Edit: While I was debugging, I noticed despite the configuration having ssh:// in front of the repo URL, it's not passed to the git clone command.

Additionally, the output of ssh-keyscan was put into the known_hosts and tmp_hosts files even when the domain wasn't able to be looked up due to unrelated issues I was having. It also seems that some of the contents in the known_hosts file is duplicated each startup.

This caused the known_hosts file to grow to about 2.5MB until I removed it. It consisted of approximately 21,000 lines, mainly with the text getaddrinfo aeiorjheriohjriot.com: Name or service not known where the domain name was my actual domain.

Unfortunately, while looking at my server logs, I lost the scroll back in my terminal for the above mentioned issues and can no longer reproduce them with the exception of the duplicated entries in my known_hosts file and the missing port argument on the ssh-keyscan command.

Sorry, one last edit: I think this line is the cause of the duplicate entries in the known_hosts file: https://github.com/abiosoft/caddy-git/blob/master/scripts.go#L119

It seems to me that the output of the known_hosts file is being sorted and duplicate lines removed. That is put into the tmp_hosts file but then we are appending the contents of the tmp_hosts into the known_hosts file, causing the duplicates.

@abiosoft
Copy link
Owner

Thanks for digging into that. I should be able to look into it this weekend.

@gganeshan
Copy link
Author

Thanks for digging into that. I should be able to look into it this weekend.

Any updates @abiosoft ?

@gganeshan
Copy link
Author

Additionally, the output of ssh-keyscan was put into the known_hosts and tmp_hosts files even when the domain wasn't able to be looked up due to unrelated issues I was having. It also seems that some of the contents in the known_hosts file is duplicated each startup.

I saw the same behavior in my container.

gganeshan pushed a commit to gganeshan/docker-caddy that referenced this issue Oct 19, 2017
caddy-git is unable to clone repos with non-standard port URL as
documented in abiosoft/caddy-git#76

This commit only attempts to provide a workaround for
this specific use case.

caddy-git is now at a [specific revision](https://github.com/abiosoft/caddy-git/tree/186c1c7e0b3c8e3c1edae20e45a782acddb37660) which does not have this issue.

This commit uses [go-getter](https://github.com/joewalnes/go-getter) to fetch caddy-git at a
specific revision

WARNING: this version of caddy-git is a few revisions behind and
may contain some known issues addressed by more recent commits.
@mdcollins05
Copy link

Any luck on working through this issue @abiosoft ? Unfortunately, this breaks one of my web servers and prevents it from starting.

@gganeshan
Copy link
Author

Any updates on this @abiosoft ??

@arahmanhamdy
Copy link

any updates @abiosoft ?

@pixie79
Copy link

pixie79 commented Nov 27, 2018

This bug appears to still be present
31 user1 0:00 bash /tmp/caddy265241523 -i /home/user1/.ssh/id_rsa clone -b develop [email protected]:2222/cop/policy.git /repo
33 user1 0:00 /usr/bin/git clone -b develop [email protected]:2222/cop/policy.git /repo
36 user1 0:00 bash /tmp/.git_ssh.31 [email protected] git-upload-pack '2222/cop/policy.git'
37 user1 0:00 ssh -i /home/user1/.ssh/id_rsa [email protected] git-upload-pack '2222/cop/policy.git'

As you can see the port 2222 is being added to the path and not added as a -p port variable to the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants