Setup Git Remote SSH (git-upload-pack / git-receiv

2020-04-08 14:25发布

问题:

I have a server with SSH access and I want to place a Git origin repo there. I just created a --bare --shared repo locally and copied it to the server per SCP. Now I wanted to clone this repo per SSH url. I tried

ssh://USERNAME@HOST/folder1/folder2/gifolder.git
ssh://USERNAME:PASSWORD@HOST/folder1/folder2/gifolder.git
ssh://USERNAME@HOST:PORT/folder1/folder2/gifolder.git
ssh://USERNAME@HOST:/folder1/folder2/gifolder.git

and some more combinations of the above. But Git always says

"fatal: The remote end hung up unexpectedly"

although I'm enabled to connect per SSH with USERNAME and PASSWORD to HOST.

Is it possible to work with git in the way I want to, or do I have to setup it completely different?

UPDATE:

I configured Git Extension to use OpenSSH instead of Putty and now OpenSSH asks me to enter the password after "clone". When I'm entering the correct password I'm getting the following error:

bash: git-upload-pack: command not found

(OpenSSH seems to get a connection to the server, because it wants me to re-enter my password when i'm entering something else) So. Now I need to fix that new problem. First of all: I'm not enabled to install git on the server. Is it possible to make "git-upload-pack" and "git-receive-pack" available without installing git?

Thanks again

UPDATE2 - SOLUTION:

The solution was to integrate the remote repository-directory as a local directory per SSH/SFTP. I'm using http://www.expandrive.com/ for that purpose. Thanks

回答1:

You shouldn't need to enter a password when establishing an ssh connection:
If your public key is published on ~/.ssh/authorized_keys, this should be enough.

You might need a password if your private key is protected by a passphrase (in which case, see "ssh daemon asks for a password", you could need an ssh-agent).

Otherwise, see "Unable to Git-push master to Github" for more ssh debugging tips, including:

  • ssh -vvvT ssh://USERNAME@HOST (make sure HOME is defined, especially if you are on Windows: see "Heroku push master ssh problem")
  • check the log of the sshd on the server (for instance in /var/log/secure, but it can vary depending on the Os)

Openssh is a safer choice (and packaged with mysysgit), but it still requires that you define your %HOME% properly.

Again, ssh -vvvT will help here.

First of all: I'm not enabled to install git on the server.
Is it possible to make "git-upload-pack" and "git-receive-pack" available without installing git?

No, it isn't possible.

git must be installed, and in the path of sshd (the ssh daemon running on the server).


The OP andineupert concludes in the comments:

Due to the need to install git on the server (which I couldn't) I had to integrate the remote repo-dir as a local dir per SSH/SFTP.
Now everything's working.



回答2:

You need the binaries git-upload-pack & git-receive-pack in the path on the remote while an ssh is being executed.

If not configure them for every remote link in your repository like this

git config remote.origin.uploadpack /somepath/git/git-upload-pack
git config remote.origin.receivepack /somepath/git/git-receive-pack

where origin is the remote.