0

I followed this tutorial (in french), which is very well explained and understandable. I have knowledge of GIT, because I use my own server to version my projects in Gitlab.

I am asked to see the progress of a project. So I try for some days to install GIT on a shared host OVH (PRO account).

The final goal is to reproduce what is explained in the tutorial, and merge the code directly on the OVH server.

I follow the steps.

  1. I initializes the git on the server : git init --bare
  2. I then created a local folder, and I cling it to the remote git : git remote add origin ssh://user@ftp.domain_name.com/folder/test.git
  3. Then I try to push the local code with the remote : git push origin master

And I get the following error : fatal: protocol error: bad line length character: Usin

What is this error? Why do I get this, whatever the method used?

EDIT :

$  GIT_TRACE=2 GIT_TRACE_PACKET=2 git push origin master
10:53:29.947071 git.c:348               trace: built-in: git 'push' 'origin' 'master'
10:53:29.947071 run-command.c:335       trace: run_command: 'C:\Program Files (x86)\PuTTY\plink.exe' 'user@ftp.domaine_name.com' 'git-receive-pack '\''/folder/test.git'\'''
fatal: protocol error: bad line length character: Usin

EDIT 2 : Running another commands :

ssh user@ftp.domain_name.com git-receive-pack folder/test.git
00700000000000000000000000000000000000000000 capabilities^{} report-status delete-refs side-band-64k ofs-delta
0000

Or (from the root /folder):

ssh user@ftp.domain_name.com git-receive-pack /folder/test.git
fatal: '/folder/test.git' does not appear to be a git repository

And if I do a ls in the remote git folder :

~/folder/test.git $ ls
    branches  config  description  HEAD  hooks  info  objects  refs
w3spi
  • 4,380
  • 9
  • 47
  • 80
  • Possible duplicate of [Git Remote: Error: fatal: protocol error: bad line length character: Unab](http://stackoverflow.com/questions/8170436/git-remote-error-fatal-protocol-error-bad-line-length-character-unab) – Arnaud Christ Nov 20 '15 at 09:25
  • Try running the command with `GIT_TRACE=2` and `GIT_TRACE_PACKET=2`: `GIT_TRACE=2 GIT_TRACE_PACKET=2 git push origin master`. This will cause Git to spit out a fair amount of debugging information which may help you understand what is going on a little better. – John Szakmeister Nov 20 '15 at 09:44
  • @jszakmeister Thank you. Indeed, got some more explained errors. Please see my updated post – w3spi Nov 20 '15 at 09:54
  • I'd suggest trying to run the receive pack command as suggested in the link by @ArnaudChrist. I think it would be helpful to see the whole error string, and git is apparently not showing you it, even with tracing turned on. :-( – John Szakmeister Nov 20 '15 at 10:08
  • @jszakmeister Following your comment, I add new errors messages – w3spi Nov 20 '15 at 10:15
  • So which path is really correct: `~/folder/test.git` or `folder/test.git`? It looks like the former. Perhaps you need to adjust the `origin` remote to point to the correct repository, because the trace line is showing that it's trying to use the latter. – John Szakmeister Nov 20 '15 at 10:56
  • That should've been "or `/folder/test.git`". I think you need to update your remote with something like: `git remote set-url origin user@ftp.domain_name.com:folder/test.git` or `git remote set-url origin ssh://user@ftp.domain_name.com/home/user/folder/test.git`. – John Szakmeister Nov 20 '15 at 11:07
  • @jszakmeister Still same error. Also, I have tried to add SSH keys on local and distant, and still this damn error – w3spi Nov 20 '15 at 11:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95688/discussion-between-jszakmeister-and-zl3n). – John Szakmeister Nov 20 '15 at 11:20
  • Maybe this can help: https://docs.ovh.com/fr/hosting/24-days/day07/ – PaulH Nov 19 '20 at 13:57

2 Answers2

1

I just tried my own tutorial (which you asked for help onto) to if it works and it still does. I believe there's an issue in the way you understand the tutorial or in your Windows Git configuration.

Here's what I did step by step:

Supposing you have a git folder in your OVH's server home dir. On my local machine:

$ mkdir test.git
$ cd test.git
$ git init --bare
$ cd ..
$ scp -r test.git {user}@ssh.cluster{XXX}.ovh.net:git
$ rm -rf test.git

If you already having issues here, there's definitely something wrong with your Git config. Then, let's use the newly created repo:

$ git clone {user}@ssh.cluster{XXX}.ovh.net:git/test.git

That's it.

I don't have any specific Git configuration that says whether to use HTTPS over SSH or such.

Keep in mind that, as far as I remember, the OVH server hasn't access to the outside world unless by FTP and SSH. You might want to verify this tho.

eexit
  • 138
  • 2
  • 8
0

For OVH Hébergement Web mutualisé, I found the following solution.

-> Generate public/private key pair through PuTTYgen PuTTY Key Generator

-> Add your public key to the server in this well hidden location:

Mon Compte > Mes Services > Clés SSH > Ajouter clé SSH > Dédié

https://www.ovh.com/manager/dedicated/#/billing/autorenew/ssh

-> Use Pageant (Putty authentication agent) and add the private key corresponding to the public key configured through the OVH manager

-> Test that SSH works:

From the local machine command prompt:

C:\gittest> ssh myusername@ftp.cluster006.ovh.net

It provides a shell on the remote machine after entering the password for the private key corresponding to the public key configured on the server

-> On the remote machine do:

Welcome to OVH
username@ssh02.cluster006.gra.hosting.ovh.net (php/7.3/production/stable) ~ $ mkdir gittest
username@ssh02.cluster006.gra.hosting.ovh.net (php/7.3/production/stable) ~ $ cd gittest
username@ssh02.cluster006.gra.hosting.ovh.net (php/7.3/production/stable) ~/gittest $ git init
Dépôt Git vide initialisé dans /home/username/gittest/.git/
username@ssh02.cluster006.gra.hosting.ovh.net (php/7.3/production/stable) ~/gittest $ pwd
/homez.732/myusername/gittest
username@ssh02.cluster006.gra.hosting.ovh.net (php/7.3/production/stable) ~/gittest $ exit

!! homez.732 is to be used in the git clone command !!

-> Now on the local machine

C:\> git clone ssh://myusername@ssh.cluster006.hosting.ovh.net/homez.732/myusername/gittest/ -v
Cloning into 'gittest'...
remote: Décompte des objets: 3, fait.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
C:> cd gittest
C:\gittest>

In my case, I have a fail when I try direct access without homez.732 like

C:\> git clone ssh://username@ftp.cluster006.ovh.net:gittest/
Cloning into 'gittest'...
fatal: '/' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
PaulH
  • 2,918
  • 2
  • 15
  • 31
  • Merci. Entre temps j’ai trouvé une méthode bien plus performante . Si ça t’intéresse, je peux écrire une réponse – w3spi Aug 29 '20 at 05:32
  • @w3spi c'est quoi la methode ? – Dezz H Oct 09 '20 at 14:44
  • @PaulH No, everything is happening on your pc. You push your modifications into Gitlab. The credentials for your FTP can be found on your pc ONLY. [`git-ftp`](https://github.com/git-ftp/git-ftp) compares the changes with the commit ID and the one on the ftp using the `.git-ftp.log` file. It is you locally who pushes the modifications on the FTP, the git only serves to compare the information. The gain ? One command line and upload all files at valid location with [`git-ftp push`](https://github.com/git-ftp/git-ftp) – w3spi Nov 19 '20 at 14:20